我正在将谷歌地图 api 从 v2 升级到 v3。出于某种原因,我的地图将无法加载。我通过 api 和其他一些位置遵循了代码大纲。
这是我的代码:我是否正确放置了变量?有什么帮助吗?地图可以在Casadragones找到
var marker;
function load() {
//get $result from browserdetect.php
//if (GBrowserIsCompatible()) {
// *** if (is_browser_compatible()){ ***
geocoder = new google.maps.Geocoder();
//geocoder = new GClientGeocoder();
var mapOptions = {
zoom: 2,
center: new google.maps.LatLng(40.513799, -35.375977),
mapTypeControl: true,
panControl: true;
zoomControl: true;
mapTypeId: google.maps.MapTypeId.ROADMAP
}
mapobj = new google.maps.Map(document.getElementById('map'), mapOptions);
/*
mapobj = new GMap2(document.getElementById('map'));
mapobj.addControl(new GLargeMapControl3D());
mapobj.addControl(new GMapTypeControl());
//mapobj.setCenter(new GLatLng(28.728149, -88.992889),3); // old
mapobj.setCenter(new GLatLng(40.513799, -35.375977), 2); // center in Atlantic in order to show US and UK
*/
// Change this depending on the name of your PHP file
/*GDownloadUrl("<? bloginfo('template_url'); ?>/phpsqlsearch_genxml.php", function(data) {
var xml = GXml.parse(data);*/
downloadUrl("<? bloginfo('template_url'); ?>/phpsqlsearch_genxml.php", function(data) {
var xml = parseXml(data);
var markers = xml.documentElement.getElementsByTagName('marker');
for (var i = 0; i < markers.length; i++) {
var name = markers[i].getAttribute("name");
var address = markers[i].getAttribute("address");
var city = markers[i].getAttribute("city");
var state = markers[i].getAttribute("state");
var zipcode = markers[i].getAttribute("zipcode");
var phone = markers[i].getAttribute("phone");
var pairing = markers[i].getAttribute("pairing");
var type = markers[i].getAttribute("type");
var point = new google.maps.LatLng(parseFloat(markers[i].getAttribute("lat")),
parseFloat(markers[i].getAttribute("lng")));
//var point = new GLatLng(parseFloat(markers[i].getAttribute("lat")),
// parseFloat(markers[i].getAttribute("lng")));
marker = createMarker(point, name, address, city, state, zipcode, phone, type);
marker.setMap(mapobj);
//mapobj.addOverlay(marker);
}
});
//}
}
dom 事件和其他一切都在别处。我认为这是最麻烦的代码。