codice:
function initializeMap(lat,lng,zm,mkr1,mkr2,mkr3,mkr4,mkr5,mkr6,mkr7,mkr8,mkr9,mkr10){
var mapOptions = {
mapTypeId: google.maps.MapTypeId.ROADMAP,
center: new google.maps.LatLng(lat,lng),
zoom: zm,
streetViewControl:false,
scaleControl:false,
zoomControl:false,
};
map = new google.maps.Map(document.getElementById("googleMap"), mapOptions);
$( document ).bind( "pageshow", function( event, data ){ google.maps.event.trigger(map, 'resize');
});
var paths = [
new google.maps.LatLng(mkr1,mkr2),
new google.maps.LatLng(mkr3,mkr4),
new google.maps.LatLng(mkr5,mkr6),
new google.maps.LatLng(mkr7,mkr8),
new google.maps.LatLng(mkr9,mkr10)
];
var userCoordinate = new google.maps.Polyline({
path: paths,
strokeColor: "#00b71e",
strokeOpacity: 0.8,
strokeWeight: 2
});
userCoordinate.setMap(map);
var marker = new google.maps.Marker({
position: new google.maps.LatLng(mkr1,mkr2),
map: map
});
var marker2 = new google.maps.Marker({ position:
new google.maps.LatLng(mkr3,mkr4),
map: map
});
var marker3 = new google.maps.Marker({
position: new google.maps.LatLng(mkr5,mkr6),
map: map
});
var marker4 = new google.maps.Marker({
position: new google.maps.LatLng(mkr7,mkr8),
map: map
});
var marker5 = new google.maps.Marker({
position: new google.maps.LatLng(mkr9,mkr10),
map: map
});
Essendo alle prime armi con la programmazione ho risolto inserendo 10 parametri per tutti i markers che mi servono, per poi inserire le coordinate della mappa e dei makers al click con onClick="initializeMap(tutte le vari coordinate)". Volevo sapere se invece, è possibile inserire come parametro della funzione un array che sarà riempito come accade adesso, da un click proveniente da un' altra pagina.