Question

I have successfully added multiple markers to a Google map and now I want to add an info window to each marker. I've tried multiple ways with no luck.

What I would like if for an info window with the property_title to popup when the marker is clicked on.

Here is what I have so far.

var data = 

{ "property": [
{"property_id": 1, "property_title": "property 1", "property_img": "imag1", "longitude": 1234, "latitude": 1234, "width": 500, "height": 375},
{"property_id": 2, "property_title": "property 2", "property_img": "imag1", "longitude": 1234, "latitude": 1234, "width": 500, "height": 375},
{"property_id": 3, "property_title": "property 3", "property_img": "imag1", "longitude": 1234, "latitude": 1234, "width": 500, "height": 375},
{"property_id": 4, "property_title": "property 4", "property_img": "imag1", "longitude": 1234, "latitude": 1234, "width": 500, "height": 375},
{"property_id": 5, "property_title": "property 5", "property_img": "imag1", "longitude": 1234, "latitude": 1234, "width": 500, "height": 375}
]};             

    var markers = [];
    for (var i = 0; i < 5; i++) {
      var dataProperty = data.property[i];
      var latLng = new google.maps.LatLng(dataProperty.latitude,
          dataProperty.longitude);
      var marker = new google.maps.Marker({
        position: latLng
      });
      markers.push(marker);
    }
Was it helpful?

Solution

Please refer the working demo below.

http://jsfiddle.net/RJPKJ/1/

for (i = 0; i < 5; i++){                       
var dataProperty = dataitem.property[i];     
latitudetest =dataProperty.latitude;
longitudetest = dataProperty.longitude;
var data= dataProperty.property_title;    
var myLatlng = new google.maps.LatLng(latitudetest, longitudetest);
}

OTHER TIPS

have you tried this Google Maps JavaScript API v3

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top