Google maps api 3 谷歌地图标记和多段线颜色未在IE7/8中渲染
我有一个谷歌地图v3在我的网站上显示标记和多段线。每组标记+多段线都有自己的颜色(红色、黄色、蓝色等)。这在FF/Chrome/Safari中可以正常工作,但在IE7/8中不行(在IE9中可以正常工作) 以下是IE8/XP中的标记: 标记应如下所示(铬色): DevTool或Firebug Lite中没有js错误 下面是我用来显示标记和多段线的代码:Google maps api 3 谷歌地图标记和多段线颜色未在IE7/8中渲染,google-maps-api-3,internet-explorer-8,internet-explorer-7,Google Maps Api 3,Internet Explorer 8,Internet Explorer 7,我有一个谷歌地图v3在我的网站上显示标记和多段线。每组标记+多段线都有自己的颜色(红色、黄色、蓝色等)。这在FF/Chrome/Safari中可以正常工作,但在IE7/8中不行(在IE9中可以正常工作) 以下是IE8/XP中的标记: 标记应如下所示(铬色): DevTool或Firebug Lite中没有js错误 下面是我用来显示标记和多段线的代码: Maps = { googleMap: null, paths: [], wayPoints: null, col
Maps = {
googleMap: null,
paths: [],
wayPoints: null,
colors: ["#00aeef", "#ec008c", "#41ad49", "#d2232a", "#fff200"],
minZoomLevel: 2,
init: function () {
var mapOptions = {
zoom: Maps.minZoomLevel,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
Maps.googleMap = new google.maps.Map(document.getElementById("map_canvas"), mapOptions);
google.maps.event.addListener(Maps.googleMap, 'zoom_changed', function() {
if (Maps.googleMap.getZoom() < Maps.minZoomLevel)
Maps.googleMap.setZoom(Maps.minZoomLevel);
});
},
plotPaths: function (paths) {
if (paths && paths.length === 0) {
var latLng = new google.maps.LatLng(41.850033,-87.6500523);
Maps.googleMap.setCenter(latLng);
return;
}
Maps.paths = paths;
//console.log(Maps.paths);
Maps.wayPoints = [];
for (pathIndex in Maps.paths) {
Maps.wayPoints[pathIndex] = [];
}
for (pathIndex in Maps.paths) {
for (addressIndex in Maps.paths[pathIndex]) {
Maps.getLatLong(Maps.paths[pathIndex][addressIndex], pathIndex, Maps.addWaypoint);
}
}
},
addWaypoint: function(pathIndex, latLng, address) {
// console.log("pathIndex: " + pathIndex);
if (latLng === null) {
Maps.googleMap.setCenter(new google.maps.LatLng(32.1574351, -82.90712300000001));
return;
}
// console.log("callback - latLng: " + latLng.toString());
Maps.wayPoints[pathIndex].push(latLng);
if (Maps.wayPoints[pathIndex].length == Maps.paths[pathIndex].length) {
if (typeof console !== "undefined") {
console.log("Address: " + address);
console.log(Maps.wayPoints[pathIndex]);
console.log("Color: " + Maps.colors[pathIndex - 1]);
}
Maps.setShipmentPath(Maps.wayPoints[pathIndex], Maps.colors[pathIndex - 1]);
}
var marker = new google.maps.Marker({
position: latLng,
map: Maps.googleMap,
title: address,
icon: {
path: google.maps.SymbolPath.CIRCLE,
scale: 4,
fillColor: Maps.colors[pathIndex - 1],
fillOpacity: 1.0,
strokeColor: Maps.colors[pathIndex - 1]
}
});
Maps.googleMap.setCenter(latLng);
},
setShipmentPath: function (wayPoints, color) {
var lineSymbol = {
path: 'M 0,-1 0,1',
strokeOpacity: 1,
scale: 4
};
var shipmentPath = new google.maps.Polyline({
path: wayPoints,
strokeColor: color,
strokeOpacity: 0,
strokeWeight: 10,
geodesic: true,
icons: [{
icon: lineSymbol,
offset: '0',
repeat: '20px'
}]
});
shipmentPath.setMap(Maps.googleMap);
},
getLatLong: function (address, pathIndex, callback) {
// console.log("Address: " + address);
var geocoder = new google.maps.Geocoder();
geocoder.geocode(
{'address': address},
function(results, status) {
var latLng = null;
if (status !== google.maps.GeocoderStatus.OK) {
if (typeof console !== "undefined") {
console.log("Error!");
console.log(status);
}
return;
}
if (results && results.length > 0) {
// console.log("Formatted Address: " + results[0].formatted_address);
// console.log("Lat Long: " + results[0].geometry.location.toString());
latLng = results[0].geometry.location;
if (callback) {
callback(pathIndex, latLng, results[0].formatted_address);
}
}
}
);
}
};
对我来说,这是一行代码:
<meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible">
在我的HTML标题顶部。对我来说,它最终是以下代码行:
<meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible">
在我的HTML标题顶部。也许你应该分享一些代码?使用firefox和firebug,而不是lite版本。Firebug Lite for Chrome不会记录所有错误。或者“工作”一把。@MrUpsidown标记和多段线在FF或Chrome中都能完美工作,并且在两种浏览器中都没有js错误。问题只在于IE8。我只是建议您在FF上使用Firebug,而不是Firebug Lite,因为根据我的经验,它有时无法记录非Lite版本记录的一些错误。像那样调试代码是很困难的。请提供网页或小提琴的URL。试试看,也许你应该共享一些代码?使用firefox和firebug,而不是lite版本。Firebug Lite for Chrome不会记录所有错误。或者“工作”一把。@MrUpsidown标记和多段线在FF或Chrome中都能完美工作,并且在两种浏览器中都没有js错误。问题只在于IE8。我只是建议您在FF上使用Firebug,而不是Firebug Lite,因为根据我的经验,它有时无法记录非Lite版本记录的一些错误。像那样调试代码是很困难的。请提供一个页面或小提琴的URL。当我没有那一行测试它时,Try似乎没有什么区别。当我没有那一行测试它时,Try似乎没有什么区别。