Skip to content

Instantly share code, notes, and snippets.

@flakerimi
Created October 23, 2016 14:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save flakerimi/9984172a911fd1bde7464e67686bd34d to your computer and use it in GitHub Desktop.
Save flakerimi/9984172a911fd1bde7464e67686bd34d to your computer and use it in GitHub Desktop.
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