[googlemaps] Added setOptions and setFields to Autocomplete types for (#36014)

* included types for registerPanoProvider opts

* removed an additional r from registerPanoProvider

* removed PanoProviderOptions

* added correct PanoProviderOptions

* included setOptions method for HeatmapLayer

* new tests for HeatmapLayer setOptions

* added setFields type to Autocomplete

* added setOptions to Autocomplete
This commit is contained in:
Sean Rennie 2019-06-08 03:12:28 +02:00 committed by Andrew Casey
parent d8095fbf3d
commit 7ed189d4b3
2 changed files with 266 additions and 207 deletions

View File

@ -1,7 +1,7 @@
// Test file for Google Maps JavaScript API Definition file
let mapOptions: google.maps.MapOptions = {
backgroundColor: "#fff",
backgroundColor: '#fff',
center: { lat: -25.363, lng: 131.044 },
clickableIcons: true,
controlSize: 30,
@ -10,7 +10,7 @@ let mapOptions: google.maps.MapOptions = {
fullscreenControlOptions: {
position: google.maps.ControlPosition.RIGHT_TOP
},
gestureHandling: "cooperative",
gestureHandling: 'cooperative',
scrollwheel: true,
styles: [
{
@ -36,30 +36,33 @@ let mapOptions: google.maps.MapOptions = {
};
/***** Create map *****/
let map: google.maps.Map = new google.maps.Map(
document.getElementById('map'),
mapOptions
);
let map: google.maps.Map = new google.maps.Map(document.getElementById('map'), mapOptions);
/***** Fitting map to bounds *****/
map.fitBounds({
north: 10,
east: 10,
west: 10,
south: 10
}, 50);
map.fitBounds(
{
north: 10,
east: 10,
west: 10,
south: 10
},
50
);
map.fitBounds({
east: 10,
north: 10,
south: 10,
west: 10
}, {
bottom: 100,
left: 150,
right: 150,
top: 50
});
map.fitBounds(
{
east: 10,
north: 10,
south: 10,
west: 10
},
{
bottom: 100,
left: 150,
right: 150,
top: 50
}
);
/***** Pan map to bounds *****/
map.panToBounds({
@ -67,34 +70,39 @@ map.panToBounds({
east: 10,
west: 10,
south: 10
})
map.panToBounds({
north: 10,
east: 10,
west: 10,
south: 10
}, 50)
map.panToBounds({
east: 10,
north: 10,
south: 10,
west: 10
}, {
bottom: 100,
left: 150,
right: 150,
top: 50
});
map.panToBounds(
{
north: 10,
east: 10,
west: 10,
south: 10
},
50
);
map.panToBounds(
{
east: 10,
north: 10,
south: 10,
west: 10
},
{
bottom: 100,
left: 150,
right: 150,
top: 50
}
);
/***** Data *****/
new google.maps.Data();
new google.maps.Data({ map: map });
var latLng = new google.maps.LatLng(52.201203, -1.724370),
var latLng = new google.maps.LatLng(52.201203, -1.72437),
feature = new google.maps.Data.Feature(),
geometry = new google.maps.Data.Geometry();
@ -104,7 +112,7 @@ data.add(feature);
data.add({
geometry: latLng,
id: "Test feature",
id: 'Test feature',
properties: {}
});
@ -122,15 +130,15 @@ data.setStyle(style);
data.setStyle({
clickable: true,
cursor: "pointer",
fillColor: "#79B55B",
cursor: 'pointer',
fillColor: '#79B55B',
fillOpacity: 1,
icon: { url: "//maps.google.com/mapfiles/ms/icons/blue.png" } as google.maps.Icon,
shape: { coords: [1, 2, 3], type: "circle" },
strokeColor: "#79B55B",
icon: { url: '//maps.google.com/mapfiles/ms/icons/blue.png' } as google.maps.Icon,
shape: { coords: [1, 2, 3], type: 'circle' },
strokeColor: '#79B55B',
strokeOpacity: 1,
strokeWeight: 1,
title: "string",
title: 'string',
visible: true,
zIndex: 1
});
@ -138,35 +146,47 @@ data.setStyle({
data.overrideStyle(feature, { visible: true });
data.revertStyle(feature);
data.addGeoJson({ "type": "Feature", "geometry": { "type": "Point", "coordinates": [59.327090, 18.103701] } });
data.addGeoJson({
"type": "FeatureCollection",
"features": [{
"type": "Feature",
"properties": { "dymmy": "7", },
"geometry": {
"type": "Polygon",
"coordinates": [[[123.61, -22.14], [122.38, -21.73], [121.06, -21.69], [119.66, -22.22], [119.00, -23.40], [123.61, -22.14]]]
type: 'Feature',
geometry: { type: 'Point', coordinates: [59.32709, 18.103701] }
});
data.addGeoJson(
{
type: 'FeatureCollection',
features: [
{
type: 'Feature',
properties: { dymmy: '7' },
geometry: {
type: 'Polygon',
coordinates: [
[
[123.61, -22.14],
[122.38, -21.73],
[121.06, -21.69],
[119.66, -22.22],
[119.0, -23.4],
[123.61, -22.14]
]
]
}
}
}],
}, { idPropertyName: "Test feature" });
]
},
{ idPropertyName: 'Test feature' }
);
data.loadGeoJson("http://magicGeoJsonSource.com");
data.loadGeoJson('http://magicGeoJsonSource.com');
data.loadGeoJson(
"http://magicGeoJsonSource.com",
{ idPropertyName: "test" });
data.loadGeoJson('http://magicGeoJsonSource.com', { idPropertyName: 'test' });
data.loadGeoJson(
"http://magicGeoJsonSource.com",
{ idPropertyName: "test" },
(features) => {
for (var i = 0, len = features.length; i < len; i++) {
console.log(features[i].getId());
}
});
data.loadGeoJson('http://magicGeoJsonSource.com', { idPropertyName: 'test' }, features => {
for (var i = 0, len = features.length; i < len; i++) {
console.log(features[i].getId());
}
});
data.toGeoJson((feature) => { });
data.toGeoJson(feature => {});
var dataMouseEvent: google.maps.Data.MouseEvent = {
feature: feature,
@ -174,7 +194,7 @@ var dataMouseEvent: google.maps.Data.MouseEvent = {
stop: (): void => {}
};
var addFeatureEvent : google.maps.Data.AddFeatureEvent = {
var addFeatureEvent: google.maps.Data.AddFeatureEvent = {
feature: feature
};
@ -182,26 +202,29 @@ var removeFeatureEvent: google.maps.Data.RemoveFeatureEvent = {
feature: feature
};
var setGeometryEvent: google.maps.Data.SetGeometryEvent = {
var setGeometryEvent: google.maps.Data.SetGeometryEvent = {
feature: feature,
newGeometry: geometry,
oldGeometry: geometry,
oldGeometry: geometry
};
var setPropertyEvent: google.maps.Data.SetPropertyEvent = {
feature: feature,
name: "test",
name: 'test',
newValue: {},
oldValue: {}
};
var removePropertyEvent: google.maps.Data.RemovePropertyEvent = {
feature: feature,
name: "test",
name: 'test',
oldValue: {}
};
var lineString = new google.maps.Data.LineString([ { lat: 52.201203, lng: -1.724370 }, { lat: 52.201203, lng: -2.724370 }]);
var lineString = new google.maps.Data.LineString([
{ lat: 52.201203, lng: -1.72437 },
{ lat: 52.201203, lng: -2.72437 }
]);
lineString.forEachLatLng(latLng => console.log(`${latLng.lat} ${latLng.lng}`));
data.setDrawingMode('LineString');
@ -217,35 +240,33 @@ var icon: google.maps.Icon = {
origin: new google.maps.Point(0, 0),
scaledSize: new google.maps.Size(32, 32),
size: new google.maps.Size(32, 32),
url: "dummy"
url: 'dummy'
};
/***** MapTypeStyle *****/
var mapTypeStyle: google.maps.MapTypeStyle ={
featureType: 'all',
var mapTypeStyle: google.maps.MapTypeStyle = {
featureType: 'all'
};
var mapTypeStyle: google.maps.MapTypeStyle ={
var mapTypeStyle: google.maps.MapTypeStyle = {
featureType: 'administrative.country',
elementType: 'all',
stylers: [],
stylers: []
};
var mapTypeStyle: google.maps.MapTypeStyle ={
var mapTypeStyle: google.maps.MapTypeStyle = {
featureType: 'landscape.natural',
elementType: 'geometry',
stylers: [],
stylers: []
};
var mapTypeStyle: google.maps.MapTypeStyle ={
var mapTypeStyle: google.maps.MapTypeStyle = {
featureType: 'poi.school',
elementType: 'labels',
stylers: [],
stylers: []
};
/***** MARKERS *****/
// Marker class
@ -258,7 +279,9 @@ google.maps.Marker.MAX_ZINDEX = 10; // $ExpectError
const marker = new google.maps.Marker();
const markerWithEmptyOptions = new google.maps.Marker({});
const markerWithEmptyReadonlyOptions = new google.maps.Marker({} as google.maps.ReadonlyMarkerOptions);
const markerWithEmptyReadonlyOptions = new google.maps.Marker(
{} as google.maps.ReadonlyMarkerOptions
);
const markerWithAllOptions = new google.maps.Marker({
anchorPoint: new google.maps.Point(0, 0),
@ -275,7 +298,7 @@ const markerWithAllOptions = new google.maps.Marker({
position: { lat: 0, lng: 0 },
title: 'test',
visible: true,
zIndex: 0,
zIndex: 0
});
const markerWithAllReadonlyOptions = new google.maps.Marker({
anchorPoint: new google.maps.Point(0, 0),
@ -292,7 +315,7 @@ const markerWithAllReadonlyOptions = new google.maps.Marker({
position: { lat: 0, lng: 0 },
title: 'test',
visible: true,
zIndex: 0,
zIndex: 0
} as google.maps.ReadonlyMarkerOptions);
// Marker methods
@ -340,7 +363,7 @@ marker.setIcon({
origin: new google.maps.Point(0, 0),
scaledSize: new google.maps.Size(10, 10),
size: new google.maps.Size(10, 10),
url: 'test',
url: 'test'
});
marker.setIcon({
anchor: new google.maps.Point(0, 0),
@ -348,9 +371,9 @@ marker.setIcon({
origin: new google.maps.Point(0, 0),
scaledSize: new google.maps.Size(10, 10),
size: new google.maps.Size(10, 10),
url: 'test',
url: 'test'
} as google.maps.ReadonlyIcon);
marker.setIcon({url: 'test'});
marker.setIcon({ url: 'test' });
marker.setIcon({
anchor: new google.maps.Point(0, 0),
fillColor: 'black',
@ -384,25 +407,23 @@ marker.setLabel({
color: 'test',
fontFamily: 'test',
fontSize: 'test',
fontWeight: 'test',
fontWeight: 'test'
});
marker.setLabel({
text: 'test',
color: 'test',
fontFamily: 'test',
fontSize: 'test',
fontWeight: 'test',
fontWeight: 'test'
} as google.maps.ReadonlyMarkerLabel);
marker.setLabel({text: 'test'});
marker.setLabel({text: 'test'} as google.maps.ReadonlyMarkerLabel);
marker.setLabel({ text: 'test' });
marker.setLabel({ text: 'test' } as google.maps.ReadonlyMarkerLabel);
marker.setLabel({}); // $ExpectError
marker.setLabel('test');
marker.setLabel(null);
marker.setMap(new google.maps.Map(document.createElement('div')));
marker.setMap(
new google.maps.StreetViewPanorama(document.createElement('div'))
);
marker.setMap(new google.maps.StreetViewPanorama(document.createElement('div')));
marker.setMap(null);
marker.setOpacity(0.5);
@ -423,7 +444,7 @@ marker.setOptions({
position: { lat: 0, lng: 0 },
title: '',
visible: true,
zIndex: 0,
zIndex: 0
});
marker.setOptions({
anchorPoint: new google.maps.Point(0, 0),
@ -440,40 +461,40 @@ marker.setOptions({
position: { lat: 0, lng: 0 },
title: '',
visible: true,
zIndex: 0,
zIndex: 0
} as google.maps.ReadonlyMarkerOptions);
marker.setOptions({});
marker.setOptions({} as google.maps.ReadonlyMarkerOptions);
marker.setPosition(new google.maps.LatLng(0, 0));
marker.setPosition({lat: 0, lng: 0});
marker.setPosition({lat: 0, lng: 0} as google.maps.ReadonlyLatLngLiteral);
marker.setPosition({ lat: 0, lng: 0 });
marker.setPosition({ lat: 0, lng: 0 } as google.maps.ReadonlyLatLngLiteral);
marker.setPosition(null);
marker.setShape({type: 'circle'}); // $ExpectError
marker.setShape({type: 'circle', coords: []}); // $ExpectError
marker.setShape({type: 'circle', coords: [0]}); // $ExpectError
marker.setShape({type: 'circle', coords: [0, 0]}); // $ExpectError
marker.setShape({type: 'circle', coords: [0, 0, 10]});
marker.setShape({type: 'circle', coords: [0, 0, 10, 0]}); // $ExpectError
marker.setShape({type: 'rect'}); // $ExpectError
marker.setShape({type: 'rect', coords: [0]}); // $ExpectError
marker.setShape({type: 'rect', coords: [0, 0]}); // $ExpectError
marker.setShape({type: 'rect', coords: [0, 0, 10]}); // $ExpectError
marker.setShape({type: 'rect', coords: [0, 0, 10, 10]});
marker.setShape({type: 'rect', coords: [0, 0, 10, 10, 10]}); // $ExpectError
marker.setShape({type: 'poly'}); // $ExpectError
marker.setShape({type: 'poly', coords: [0]}); // $ExpectError
marker.setShape({type: 'poly', coords: [0, 0]}); // $ExpectError
marker.setShape({type: 'poly', coords: [0, 0, 10]}); // $ExpectError
marker.setShape({type: 'poly', coords: [0, 0, 10, 10]});
marker.setShape({type: 'poly', coords: [0, 0, 10, 10, 10]});
marker.setShape({type: 'poly', coords: [0, 0, 10, 10, 10, 10]});
marker.setShape({type: 'test'}); // $ExpectError
marker.setShape({type: 'test', coords: [0]}); // $ExpectError
marker.setShape({type: 'test', coords: [0, 0]}); // $ExpectError
marker.setShape({type: 'test', coords: [0, 0, 0]}); // $ExpectError
marker.setShape({type: 'test', coords: [0, 0, 0, 0]}); // $ExpectError
marker.setShape({ type: 'circle' }); // $ExpectError
marker.setShape({ type: 'circle', coords: [] }); // $ExpectError
marker.setShape({ type: 'circle', coords: [0] }); // $ExpectError
marker.setShape({ type: 'circle', coords: [0, 0] }); // $ExpectError
marker.setShape({ type: 'circle', coords: [0, 0, 10] });
marker.setShape({ type: 'circle', coords: [0, 0, 10, 0] }); // $ExpectError
marker.setShape({ type: 'rect' }); // $ExpectError
marker.setShape({ type: 'rect', coords: [0] }); // $ExpectError
marker.setShape({ type: 'rect', coords: [0, 0] }); // $ExpectError
marker.setShape({ type: 'rect', coords: [0, 0, 10] }); // $ExpectError
marker.setShape({ type: 'rect', coords: [0, 0, 10, 10] });
marker.setShape({ type: 'rect', coords: [0, 0, 10, 10, 10] }); // $ExpectError
marker.setShape({ type: 'poly' }); // $ExpectError
marker.setShape({ type: 'poly', coords: [0] }); // $ExpectError
marker.setShape({ type: 'poly', coords: [0, 0] }); // $ExpectError
marker.setShape({ type: 'poly', coords: [0, 0, 10] }); // $ExpectError
marker.setShape({ type: 'poly', coords: [0, 0, 10, 10] });
marker.setShape({ type: 'poly', coords: [0, 0, 10, 10, 10] });
marker.setShape({ type: 'poly', coords: [0, 0, 10, 10, 10, 10] });
marker.setShape({ type: 'test' }); // $ExpectError
marker.setShape({ type: 'test', coords: [0] }); // $ExpectError
marker.setShape({ type: 'test', coords: [0, 0] }); // $ExpectError
marker.setShape({ type: 'test', coords: [0, 0, 0] }); // $ExpectError
marker.setShape({ type: 'test', coords: [0, 0, 0, 0] }); // $ExpectError
marker.setShape({}); // $ExpectError
marker.setShape(null);
@ -489,90 +510,89 @@ marker.setZIndex(null);
marker.addListener('animation_changed', () => {});
marker.addListener('animation_changed', (event) => {}); // $ExpectError
marker.addListener('animation_changed', event => {}); // $ExpectError
marker.addListener('click', (event) => {
marker.addListener('click', event => {
event; // $ExpectType MouseEvent
});
marker.addListener('clickable_changed', () => {});
marker.addListener('clickable_changed', (event) => {}); // $ExpectError
marker.addListener('clickable_changed', event => {}); // $ExpectError
marker.addListener('cursor_changed', () => {});
marker.addListener('cursor_changed', (event) => {}); // $ExpectError
marker.addListener('cursor_changed', event => {}); // $ExpectError
marker.addListener('dblclick', (event) => {
marker.addListener('dblclick', event => {
event; // $ExpectType MouseEvent
});
marker.addListener('drag', (event) => {
marker.addListener('drag', event => {
event; // $ExpectType MouseEvent
});
marker.addListener('dragend', (event) => {
marker.addListener('dragend', event => {
event; // $ExpectType MouseEvent
});
marker.addListener('draggable_changed', (event) => {}); // $ExpectError
marker.addListener('draggable_changed', event => {}); // $ExpectError
marker.addListener('dragstart', (event) => {
marker.addListener('dragstart', event => {
event; // $ExpectType MouseEvent
});
marker.addListener('flat_changed', () => {});
marker.addListener('flat_changed', (event) => {}); // $ExpectError
marker.addListener('flat_changed', event => {}); // $ExpectError
marker.addListener('icon_changed', () => {});
marker.addListener('icon_changed', (event) => {}); // $ExpectError
marker.addListener('icon_changed', event => {}); // $ExpectError
marker.addListener('mousedown', (event) => {
marker.addListener('mousedown', event => {
event; // $ExpectType MouseEvent
});
marker.addListener('mouseout', (event) => {
marker.addListener('mouseout', event => {
event; // $ExpectType MouseEvent
});
marker.addListener('mouseover', (event) => {
marker.addListener('mouseover', event => {
event; // $ExpectType MouseEvent
});
marker.addListener('mouseup', (event) => {
marker.addListener('mouseup', event => {
event; // $ExpectType MouseEvent
});
marker.addListener('position_changed', () => {});
marker.addListener('position_changed', (event) => {}); // $ExpectError
marker.addListener('position_changed', event => {}); // $ExpectError
marker.addListener('rightclick', (event) => {
marker.addListener('rightclick', event => {
event; // $ExpectType MouseEvent
});
marker.addListener('shape_changed', () => {});
marker.addListener('shape_changed', (event) => {}); // $ExpectError
marker.addListener('shape_changed', event => {}); // $ExpectError
marker.addListener('title_changed', () => {});
marker.addListener('title_changed', (event) => {}); // $ExpectError
marker.addListener('title_changed', event => {}); // $ExpectError
marker.addListener('visible_changed', () => {});
marker.addListener('visible_changed', (event) => {}); // $ExpectError
marker.addListener('visible_changed', event => {}); // $ExpectError
marker.addListener('zindex_changed', () => {});
marker.addListener('zindex_changed', (event) => {}); // $ExpectError
marker.addListener('zindex_changed', event => {}); // $ExpectError
/***** OverlayView *****/
// https://developers.google.com/maps/documentation/javascript/customoverlays
var div = document.createElement('div');
var div = document.createElement('div');
class Overlay extends google.maps.OverlayView {
public draw(): void {
var panes = this.getPanes();
@ -584,7 +604,7 @@ class Overlay extends google.maps.OverlayView {
panes.overlayLayer.appendChild(div);
panes.overlayMouseTarget.appendChild(div);
panes.overlayShadow.appendChild(div);
};
}
}
var overlay = new Overlay();
overlay.setMap(map);
@ -620,7 +640,7 @@ var circle1 = new google.maps.Circle({
// circleOptions with LatLngLiteral center
var circle2 = new google.maps.Circle({
center: {lat: 59.327, lng: 18.067},
center: { lat: 59.327, lng: 18.067 },
radius: 20,
fillColor: '#FF0000',
strokeColor: '#FF0000',
@ -629,7 +649,6 @@ var circle2 = new google.maps.Circle({
strokeWeight: 1
});
/***** StreetViewPanorama *****/
var panoramaOptions: google.maps.StreetViewPanoramaOptions = {
zoom: 0,
@ -642,97 +661,135 @@ var panoramaOptions: google.maps.StreetViewPanoramaOptions = {
motionTracking: true,
motionTrackingControl: true
};
var panorama = new google.maps.StreetViewPanorama(document.createElement("div"), panoramaOptions);
var panorama = new google.maps.StreetViewPanorama(document.createElement('div'), panoramaOptions);
// MVCObject method on StreetViewPanorama
var panoramaEvent = panorama.addListener("pano_changed", () => {});
var panoramaEvent = panorama.addListener('pano_changed', () => {});
/***** MVCArray *****/
// MVCArray should be generic
let mvcArrayStr = new google.maps.MVCArray<string>(["a", "b", "c"]);
mvcArrayStr.forEach((elem: string, i: number): void => { elem.toUpperCase(); });
let mvcArrayStr = new google.maps.MVCArray<string>(['a', 'b', 'c']);
mvcArrayStr.forEach(
(elem: string, i: number): void => {
elem.toUpperCase();
}
);
mvcArrayStr.getArray()[0].toUpperCase();
mvcArrayStr.getAt(0).toUpperCase();
mvcArrayStr.insertAt(2, "x");
mvcArrayStr.insertAt(2, 'x');
mvcArrayStr.pop().toUpperCase();
mvcArrayStr.push("y");
mvcArrayStr.push('y');
mvcArrayStr.removeAt(0).toUpperCase();
mvcArrayStr.setAt(0, "z");
mvcArrayStr.setAt(0, 'z');
/***** HeatMaps *****/
let heatmap = new google.maps.visualization.HeatmapLayer({
data: [new google.maps.LatLng(37.782551, -122.445368), new google.maps.LatLng(37.782745, -122.444586), new google.maps.LatLng({lat: 37.782842, lng: -122.443688})],
data: [
new google.maps.LatLng(37.782551, -122.445368),
new google.maps.LatLng(37.782745, -122.444586),
new google.maps.LatLng({ lat: 37.782842, lng: -122.443688 })
],
map: map
});
// setData Should Accept MVCArray<LatLng>
heatmap.setData(new google.maps.MVCArray<google.maps.LatLng>(
[new google.maps.LatLng(37.782551, -122.445368), new google.maps.LatLng(37.782745, -122.444586), new google.maps.LatLng({lat: 37.782842, lng: -122.443688})]
));
heatmap.setData(
new google.maps.MVCArray<google.maps.LatLng>([
new google.maps.LatLng(37.782551, -122.445368),
new google.maps.LatLng(37.782745, -122.444586),
new google.maps.LatLng({ lat: 37.782842, lng: -122.443688 })
])
);
// getData Should return MVCArray<LatLng>
let heatmapDataMvcLL = heatmap.getData<google.maps.LatLng>();
console.log(heatmapDataMvcLL.getAt(0).lat()); // should not throw
// setData Should Accept MVCArray<WeightedLocation>
heatmap.setData(new google.maps.MVCArray<google.maps.visualization.WeightedLocation>([
{ weight: 1, location: new google.maps.LatLng(37.782551, -122.445368) },
{ weight: 2, location: new google.maps.LatLng(37.782745, -122.444586) },
{ weight: 3, location: new google.maps.LatLng({lat: 37.782842, lng: -122.443688}) }
]));
heatmap.setData(
new google.maps.MVCArray<google.maps.visualization.WeightedLocation>([
{ weight: 1, location: new google.maps.LatLng(37.782551, -122.445368) },
{ weight: 2, location: new google.maps.LatLng(37.782745, -122.444586) },
{ weight: 3, location: new google.maps.LatLng({ lat: 37.782842, lng: -122.443688 }) }
])
);
// getData Should return MVCArray<LatLng>
let heatmapDataWL = heatmap.getData<google.maps.visualization.WeightedLocation>();
console.log(heatmapDataWL.getAt(0).weight); // should not throw
// setData Should Accept LatLng[]
heatmap.setData([new google.maps.LatLng(37.782551, -122.445368), new google.maps.LatLng(37.782745, -122.444586), new google.maps.LatLng({lat: 37.782842, lng: -122.443688})]);
heatmap.setData([
new google.maps.LatLng(37.782551, -122.445368),
new google.maps.LatLng(37.782745, -122.444586),
new google.maps.LatLng({ lat: 37.782842, lng: -122.443688 })
]);
// setData Should Accept WeightedLocation[]
heatmap.setData([
{ weight: 1, location: new google.maps.LatLng(37.782551, -122.445368) },
{ weight: 2, location: new google.maps.LatLng({lat: 37.782745, lng: -122.444586}) }
{ weight: 2, location: new google.maps.LatLng({ lat: 37.782745, lng: -122.444586 }) }
]);
// setOptions should required data and accepted any HeatmapLayerOptions
heatmap.setOptions({
data: [
new google.maps.LatLng(37.782551, -122.445368),
new google.maps.LatLng(37.782745, -122.444586),
new google.maps.LatLng({ lat: 37.782842, lng: -122.443688 })
],
dissipating: true,
map: map,
opacity: 8
});
/***** google.maps.places.PlacesService *****/
let service = new google.maps.places.PlacesService(new HTMLDivElement());
service.getDetails({
placeId: '-a1',
fields: ['name'],
sessionToken: new google.maps.places.AutocompleteSessionToken()
}, (result, status) => {
if (status === google.maps.places.PlacesServiceStatus.NOT_FOUND) {
return;
service.getDetails(
{
placeId: '-a1',
fields: ['name'],
sessionToken: new google.maps.places.AutocompleteSessionToken()
},
(result, status) => {
if (status === google.maps.places.PlacesServiceStatus.NOT_FOUND) {
return;
}
result.name; // $ExpectType string
}
);
result.name; // $ExpectType string
})
service.findPlaceFromQuery(
{
query: 'Big Ben London',
fields: ['name']
},
(results, status) => {
if (status === google.maps.places.PlacesServiceStatus.ERROR) {
return;
}
service.findPlaceFromQuery({
query: 'Big Ben London',
fields: ['name']
}, (results, status) => {
if (status === google.maps.places.PlacesServiceStatus.ERROR) {
return;
results[0].name; // $ExpectType string
}
);
results[0].name; // $ExpectType string
});
service.findPlaceFromPhoneNumber(
{
phoneNumber: '123456',
fields: ['name']
},
(results, status) => {
if (status === google.maps.places.PlacesServiceStatus.ERROR) {
return;
}
service.findPlaceFromPhoneNumber({
phoneNumber: '123456',
fields: ['name']
}, (results, status) => {
if (status === google.maps.places.PlacesServiceStatus.ERROR) {
return;
results[0].name; // $ExpectType string
}
results[0].name; // $ExpectType string
});
);
/***** google.maps.places.Autocomplete *****/
const autocomplete = new google.maps.places.Autocomplete(document.createElement('input'));
@ -747,7 +804,7 @@ const imageMapType = new google.maps.ImageMapType({
minZoom: 10,
name: 'name',
opacity: 0.5,
tileSize: new google.maps.Size(256, 256),
tileSize: new google.maps.Size(256, 256)
});
imageMapType.alt; // $ExpectType string
imageMapType.maxZoom; // $ExpectType number
@ -762,7 +819,7 @@ const styledMapType = new google.maps.StyledMapType([], {
alt: 'alt',
maxZoom: 20,
minZoom: 10,
name: 'name',
name: 'name'
});
styledMapType.alt; // $ExpectType string
styledMapType.maxZoom; // $ExpectType number
@ -774,13 +831,13 @@ styledMapType.tileSize; // $ExpectType Size
const directionsWaypointEmpty: google.maps.DirectionsWaypoint = {};
const directionsWaypointLocationString: google.maps.DirectionsWaypoint = {
location: '',
location: ''
};
const directionsWaypointLocationLatLng: google.maps.DirectionsWaypoint = {
location: new google.maps.LatLng(0, 0),
location: new google.maps.LatLng(0, 0)
};
const directionsWaypointLocationPlace: google.maps.DirectionsWaypoint = {
location: {query: ''},
location: { query: '' }
};
const directionsWaypointStopover: google.maps.DirectionsWaypoint = {
stopover: true

View File

@ -3116,6 +3116,8 @@ declare namespace google.maps {
getPlace(): PlaceResult;
setBounds(bounds: LatLngBounds | LatLngBoundsLiteral): void;
setComponentRestrictions(restrictions: ComponentRestrictions): void;
setFields(fields: Array<string> | undefined): void;
setOptions(options: AutocompleteOptions): void;
setTypes(types: string[]): void;
}