gpt4 book ai didi

c# - 如何在谷歌地图中使用 jquery 动态绑定(bind)多个标记

转载 作者:行者123 更新时间:2023-11-30 12:10:57 24 4
gpt4 key购买 nike

我需要根据给定的纬度和经度绑定(bind) Google map 中的“多个标记”,并绑定(bind)标记信息窗口。

我有Refereed this Link

我试过这段代码:

var myLatLng = new google.maps.LatLng(this.Latitude, this.Longtitude);

var contentString = '<span style="color:green;font-size:10pt;">Hospital Name:' + this.hospitalName + '</span><br />Address:<br />' + this.cityName + this.stateName + '<br/><br/>';
//this.hospitalName + '</br>' + this.cityName + '</br>' + this.stateName;
var infowindow = new google.maps.InfoWindow();
var marker = new google.maps.Marker({
position: myLatLng,
map: map,
icon: image,
shape: shape
});
google.maps.event.addListener(marker, 'click', function() {
infowindow.setContent(contentString);
infowindow.open(map, this);
});

最佳答案

你可以使用这样的东西,

$.each($.parseJSON(data), function() {

var myLatLng = new google.maps.LatLng(this.Latitude, this.Longtitude);
var contentString = '<span style="color:green;font-size:10pt;">Hospital Name:' + this.hospitalName + '</span><br />Address:<br />' + this.cityName + this.stateName + '<br/><br/>';
this.hospitalName + '</br>' + this.cityName + '</br>' + this.stateName;
var infowindow = new google.maps.InfoWindow();
var marker = new google.maps.Marker({
position: myLatLng,
map: map,
icon: image,
shape: shape
});
google.maps.event.addListener(marker, 'click', function() {
infowindow.setContent(contentString);
infowindow.open(map, this);
});


});

关于c# - 如何在谷歌地图中使用 jquery 动态绑定(bind)多个标记,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16733877/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com