I want to put this google maps script into a js file and pass the mapLocs array into it as a parameter from a script in the html page. Does anyone know how this could possibly be done please?
function initialize(){
var map = new google.maps.Map(document.getElementById("map"),
{
zoom: 13,
center: new google.maps.LatLng(53.408103, -2.979595),
mapTypeId: google.maps.MapTypeId.ROADMAP
});
setMarkers(map, mapLocs);
}
// To be passed in as a parameter?
var mapLocs = [
['Liverpool', 53.408103, -2.979595]
];
function setMarkers(map, locations){
for (var i = 0; i < locations.length; i++){
var places = locations[i];
var myLatLng = new google.maps.LatLng(places[1], places[2]);
var marker = new google.maps.Marker({
position: myLatLng,
draggable: false,
map: map,
title: places[0],
zIndex: places[3]
});
}
}
google.maps.event.addDomListener(window, 'load', initialize);
mapLocsintoinitialize, or beforeinitializeis defined? Or just make sure that the map script is below the script that definesmapLocsin the HTML page if it's in a different script.