<!-->MyOverlay.prototype = new google.maps.OverlayView(); /** @constructor */ function MyOverlay(map, ...) { ... }; MyOverlay.prototype.draw = function() { ... };
MyOverlay.prototype = new google.maps.OverlayView();
/** @constructor */
function MyOverlay(map, ...) { ... };
MyOverlay.prototype.draw = function() { ... };
function initLocations(latMin, lngMin, latMax, lngMax, numPoints) { let latExtent = latMax - latMin; let lngExtent = lngMax - lngMin; let tmpLocations = new Array(numPoints); for (let i = 0; i < numPoints; i++) { tmpLocations[i] = { lat: Math.random() * latExtent + latMin, lng: Math.random() * lngExtent + lngMin}; }; } return tmpLocations; } ... let locations = initLocations(-33, 117, -22, 148, 1000);
function initLocations(latMin, lngMin, latMax, lngMax, numPoints) {
let latExtent = latMax - latMin;
let lngExtent = lngMax - lngMin;
let tmpLocations = new Array(numPoints);
for (let i = 0; i < numPoints; i++) {
tmpLocations[i] = {
lat: Math.random() * latExtent + latMin,
lng: Math.random() * lngExtent + lngMin};
};
}
return tmpLocations;
...
let locations = initLocations(-33, 117, -22, 148, 1000);
function initMap() { // initialize the map let map = new google.maps.Map(document.getElementById('map'), { zoom: 3, center: {lat: -25.906174, lng: 132.409812}, }); // Add the markers to the map let markers = locations.map((location, i) => { return new google.maps.Marker({ icon: './images/pin.svg', position: location, zIndex: i, map: map }); }); // Add event listeners to the markers markers.map((marker, i) => { marker.addListener('mouseover', () => { toggleIcon(marker, true); }); marker.addListener('mouseout', () => { toggleIcon(marker, false); }); }); ... }
function initMap() {
// initialize the map
let map = new google.maps.Map(document.getElementById('map'), {
zoom: 3,
center: {lat: -25.906174, lng: 132.409812},
});
// Add the markers to the map
let markers = locations.map((location, i) => {
return new google.maps.Marker({
icon: './images/pin.svg',
position: location,
zIndex: i,
map: map
// Add event listeners to the markers
markers.map((marker, i) => {
marker.addListener('mouseover', () => {
toggleIcon(marker, true);
marker.addListener('mouseout', () => {
toggleIcon(marker, false);