所以我在我的网站上显示了一个 KMZ 图层,但不会在其他任何地方显示。这是我的 Javascript:
function getBaseUrl() {
var e = RegExp(/^.*\//);
return e.exec(window.location.href);
}
function initialize() {
function e() {
navigator.geolocation.getCurrentPosition(function(e) {
var o = new google.maps.LatLng(e.coords.latitude, e.coords.longitude);
p ? p.setPosition(o) : p = new google.maps.Marker({
position: o,
icon: "http://i.imgur.com/1VTzeOS.png",
map: map
}), map.setCenter(t);
}), setTimeout(e, 3e5);
}
var o = new google.maps.LatLng(42.449686, -71.230919), t = o, a = {
zoom: 12,
center: o,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(document.getElementById("map_canvas"), a), geoXml = new geoXML3.parser({
map: map,
singleInfoWindow: !0,
zoom: !1
}), geoXml.parseKmlString(kmlData);
for (var n = {
path: "M 0,-1 0,1",
strokeOpacity: 1,
scale: 2.5,
preserveViewport: !0
}, i = 0; i < geoXml.docs[0].gpolylines.length; i++) geoXml.docs[0].gpolylines[i].setOptions({
strokeOpacity: 1,
strokeWeight: 1,
zoom: !1,
icons: [ {
icon: n,
offset: "0",
repeat: "1px"
} ]
});
var r = new google.maps.KmlLayer({
url: parent + "parking2.kmz",
strokeWeight: 20,
strokeOpacity: 0,
preserveViewport: !0
});
r.setMap(map);
var p = (new google.maps.InfoWindow({
content: "You are here!"
}), null);
e();
}
var parent = getBaseUrl();
google.maps.event.addDomListener(window, "load", initialize);
例如 127.0.0.1/localhost 使用 xampp 或http://example.com/test/map.html时,parking2.kmz 层将不会显示。但是,它将显示在http://example.com/map.html上。有任何想法吗?