我已成功将多个标记添加到Google地图,现在我想为每个标记添加一个信息窗口。我尝试了多种方法,没有运气。
如果在点击标记时弹出property_title
的信息窗口,我想要的是什么。
这是我到目前为止所拥有的。
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);
}
答案 0 :(得分:0)
答案 1 :(得分:0)
请参阅下面的工作演示。
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);
}