multiple location points from a REST + info window
how can add an info window to each of the multiple markers i loaded on my google map?
As suggested me I run the following code on the REST service success event :
Code: Select all
var response = JSON.stringify(data);
localStorage.setItem("list_coordinate", response);
var list_coordinate = localStorage.getItem('list_coordinate');
var obj = JSON.parse(list_coordinate);
var coordsArray = obj.coordinate;
var marker;
for (var i = 0, j = coordsArray.length; i < j; i++) {
marker = new google.maps.Marker({
position: new google.maps.LatLng( coordsArray[i].latitudine, coordsArray[i].longitudine ),
title: coordsArray[i].descr,
map: Appery("googlemap_2").gmap
});
}
and it works.
but i would like to open an info window on each marker click. and when the window has been opened to allow users to click on some part of the window, save a local storage variable and navigate to another page of may application.
I tested the following code just to open a info window following in some way gmap api but it doesn't work
Code: Select all
var response = JSON.stringify(data);
localStorage.setItem("list_coordinate", response);
var list_coordinate = localStorage.getItem('list_coordinate');
var obj = JSON.parse(list_coordinate);
var coordsArray = obj.coordinate;
var marker;
var contentString = ''+
''+
''+
'Uluru'+
''+
' [b]Uluru[/b], also referred to as [b]Ayers Rock[/b], is a large ' +
'sandstone rock formation in the southern part of the '+
'Northern Territory, central Australia. It lies 335 km (208 mi) '+
'south west of the nearest large town, Alice Springs; 450 km '+
'(280 mi) by road. Kata Tjuta and Uluru are the two major '+
'features of the Uluru - Kata Tjuta National Park. Uluru is '+
'sacred to the Pitjantjatjara and Yankunytjatjara, the '+
'Aboriginal people of the area. It has many springs, waterholes, '+
'rock caves and ancient paintings. Uluru is listed as a World '+
'Heritage Site.
'+
' Attribution: Uluru, [url=http://en.wikipedia.org/w/index.php?title=Uluru&oldid=297882194]'+
'http://en.wikipedia.org/w/index.php?title=Uluru[/url] (last visited June 22, 2009).
'+
''+
'';
var infowindow = new google.maps.InfoWindow({
content: contentString
});
for (var i = 0, j = coordsArray.length; i < j; i++) {
marker = new google.maps.Marker({
position: new google.maps.LatLng( coordsArray[i].latitudine, coordsArray[i].longitudine ),
title: coordsArray[i].descr,
map: Appery("googlemap_2").gmap
});
google.maps.event.addListener(marker, 'click', function() {
infowindow.open(Appery("googlemap_2"),marker);
});
}