Created
October 23, 2016 14:28
-
-
Save flakerimi/9984172a911fd1bde7464e67686bd34d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ionViewDidLoad() { | |
var mapData = [{"lat":42.6222,"lon":21.0827,"location":"POINT A","hq":null}, | |
{"lat":42.3833,"lon":21.1675,"location":"POINT B 1","hq":null}, | |
{"lat":42.4906,"lon":21.5057,"location":"POIN C","hq":null}]; | |
let mapEle = document.getElementById('map'); | |
let map = new google.maps.Map(mapEle, { | |
center: "42.6026,20.903", | |
zoom: 16 | |
}); | |
for (let markerData of mapData) { | |
let infoWindow = new google.maps.InfoWindow({ | |
content: `<h5>${markerData.location}</h5>` | |
}); | |
let myLatLng = new google.maps.LatLng({lat: markerData.lat, lng: markerData.lon}); | |
let marker = new google.maps.Marker({ | |
position: myLatLng, | |
map: map, | |
title: markerData.location | |
}); | |
marker.addListener('click', () => { | |
infoWindow.open(map, marker); | |
}); | |
}; | |
google.maps.event.addListenerOnce(map, 'idle', () => { | |
mapEle.classList.add('show-map'); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment