我的代码看起来像这样:
var map = /*some google map - defined earlier in the code*/;
var geocoder = new google.maps.Geocoder();
var address = 'Some Address, Some Street, Some Place';
geocoder.geocode({'address':address},function(results,status){
if (status == google.maps.GeocoderStatus.OK) {
map.setCenter(results[0].geometry.location);
var infobox = new google.maps.InfoWindow({
content: 'Hello world'
});
for(i in results){
var marker = new google.maps.Marker({
map: map,
position: results[i].geometry.location
});
google.maps.event.addListener(marker, 'click', function() {
infobox.setContent('blablabla');
infobox.open(map,marker);
alert(infobox.content); //displays 'blablabla'
});
}
}
});
Run Code Online (Sandbox Code Playgroud)
基本上它是基于给定的地址字符串在单个地图上创建一些标记.它会向单击时打开的标记添加infoWindow.
问题是:infoWindow显示为空.
截图:
PS:使用Maps API V3
我的问题很简单; 我需要读出一些模板(在PHP中)并将它们发送到客户端.
对于这种数据,特别是text/html和text/javascript; 从MySQL数据库或文件中读取它们是否更昂贵?
亲切的问候
汤姆
inb4安全; 我意识到.
PS:我读过有关类似问题的其他主题,但要么与其他类型的数据有关,要么没有得到回答.