ok, ho fatto la prova con un indirizzo e pare funzionare:
codice:
function initMap() {
var geocoder = new google.maps.Geocoder();
var mapOptions = {
zoom: 15,
//center: latlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
var map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions);
geocoder.geocode({ 'address': 'Via Ximenes,20,Roma,Lazio' }, function (results, status) {
if (status == google.maps.GeocoderStatus.OK) {
map.setCenter(results[0].geometry.location);
var marker = new google.maps.Marker({
map: map,
position: results[0].geometry.location
});
} else {
alert("Geocode was not successful for the following reason: " + status);
document.getElementById("lbl_error").html = ("Geocode was not successful for the following reason: " + status);
}
});
}
adesso, come posso fare per mandargli vari indirizz e mettere altrittanti marker??
faccio la query dalla quale estrapolo dei dati che suppongo che devo passare come parametro alla funzione:
-regione
-città
-via
-civico
e lo strutturo come nell'esempio statico.
suppongo di dover ciclare sui risultati e per ogni record mettere un marker.
se così, come glieli passo i dati??