0
我有一個谷歌地圖,它從Visual Studio 2013中的本地主機上運行的GeoJSON文件加載標記。它也運行在chrome中(從IIS服務器),但將不會在IE版本11中運行。地圖顯示出來了,但JSON文件中的標記卻沒有。爲什麼會在IIS 8上使用Chrome,IE 11通過VS,但IIS 8上沒有IE 11?谷歌地圖API GeoJSON不適用於IE 11,但在Chrome中工作
var map;
var infowindow = new google.maps.InfoWindow({ });
function initialize() {
map = new google.maps.Map(document.getElementById('googleMap'), {
center: new google.maps.LatLng(15.508742, -0.120850),
zoom: 2,
mapTypeId: google.maps.MapTypeId.HYBRID,
scrollwheel: false
});
google.maps.event.addListener(map, 'click', function() {
infowindow.close();
});
// Load a GeoJSON from the same server as our demo.
map.data.loadGeoJson('locations.json');
// Set event listener for each feature.
map.data.addListener('click', function (event) {
infowindow.setContent("<div> " + event.feature.getProperty('city') + " " + event.feature.getProperty('date') + "<br>" + event.feature.getProperty('course') + "<br>Sponsored by: " + event.feature.getProperty('sponsor') + "<br>" + "<a href=" + "/Training.aspx" + ">Click here to Register</a>" + "</div>");
infowindow.setPosition(event.latLng);
infowindow.setOptions({ pixelOffset: new google.maps.Size(0, -34) });
infowindow.open(map);
});
map.data.addListener('mouseover', function (event) {
//infowindow.setContent("<div class=\"map_info_box\" > " + event.feature.getProperty('city') + " " + event.feature.getProperty('date') + "<br>" + event.feature.getProperty('course') + "<br>Sponsored by: " + event.feature.getProperty('sponsor') + "<br>" + "<a href=" + "/Training.aspx" + ">Click here to Register</a>" + "</div>");
infowindow.setContent("<div> " + event.feature.getProperty('city') + " " + event.feature.getProperty('date') + "<br>" + event.feature.getProperty('course') + "<br>Sponsored by: " + event.feature.getProperty('sponsor') + "<br>" + "<a href=" + "/Training.aspx" + ">Click here to Register</a>" + "</div>");
infowindow.setPosition(event.latLng);
infowindow.setOptions({ pixelOffset: new google.maps.Size(0, -34) });
infowindow.open(map);
});
}
google.maps.event.addDomListener(window, 'load', initialize);
你做了什麼基本的調試? – Andy 2014-10-31 16:00:29
有沒有可以使用的'addGeoJSON'方法? [看來你可以用它來加載本地數據。](http://stackanswers.com/questions/25334931/loading-a-local-geojson-file-and-using-it-with-the-google-maps- javascript-api-v3) – Andy 2014-10-31 16:05:08
感謝您的快速回復。 JSON數據是動態的,並且該文件將從Sql Server中的表中生成,這就是爲什麼位置不需要在腳本本身中的原因。 – Sasquatch 2014-10-31 16:11:47