Javascript 另一个GMap问题
在过去的一个小时里,我一直在查看这段代码,我不明白为什么html弹出窗口不会显示,我可能遗漏了一些简单的东西,因为没有报告错误Javascript 另一个GMap问题,javascript,google-maps,Javascript,Google Maps,在过去的一个小时里,我一直在查看这段代码,我不明白为什么html弹出窗口不会显示,我可能遗漏了一些简单的东西,因为没有报告错误 var map; var markers = new Array(); var geocoder; function initialize() { if (GBrowserIsCompatible()) { map = new GMap2(document.getElementById("map")); map.setCenter
var map;
var markers = new Array();
var geocoder;
function initialize() {
if (GBrowserIsCompatible()) {
map = new GMap2(document.getElementById("map"));
map.setCenter(new GLatLng(<?php echo $map_center; ?>), 17);
map.addControl(new GLargeMapControl());
map.addControl(new GMapTypeControl());
geocoder = new GClientGeocoder();
}
}
function createMarker(point,number) {
var marker = new GMarker(point);
marker.value = number;
GEvent.addListener(marker, "click", function() {
map.openInfoWindowHtml(point, createInfoText());
});
return marker;
}
function createInfoText() {
var html = '<p>hello world</p>';
return html;
}
$(document).ready(function () {
initialize();
var point = new GLatLng("51.2357, -0.5726");
map.addOverlay(createMarker(point,1));
});
var映射;
var markers=新数组();
var地理编码器;
函数初始化(){
if(GBrowserIsCompatible()){
map=新的GMap2(document.getElementById(“map”);
setCenter(新GLatLng(),17);
addControl(新的GlargeMappControl());
addControl(新的GMapTypeControl());
geocoder=新的GClientGeocoder();
}
}
函数createMarker(点、数){
var标记=新的GMarker(点);
marker.value=数字;
addListener(标记“单击”,函数(){
openInfoWindowHtml(point,createInfoText());
});
返回标记;
}
函数createInfoText(){
var html='helloworld';
返回html;
}
$(文档).ready(函数(){
初始化();
var点=新玻璃(“51.2357,-0.5726”);
map.addOverlay(createMarker(点,1));
});
提前感谢所有的几行看起来有点古怪 这个:
var point = new GLatLng("51.2357, -0.5726");
应该是:
var point = new GLatLng(51.2357, -0.5726);
对于这个:
map.setCenter(new GLatLng(<?php echo $map_center; ?>), 17);
map.setCenter(新GLatLng(),17);
你应该确保
$map\u center
是一个,
由两个浮点数组成的分隔字符串。我真的需要停止偷懒并写出代码lol感谢var point=new GLatLng(51.2357,-0.5726);解决了这个问题