gpt4 book ai didi

javascript - Chrome 更新 38.0.2125.104 m 后,Google Map API v3 不显示多边形

转载 作者:行者123 更新时间:2023-12-03 11:36:41 26 4
gpt4 key购买 nike

我于 2014 年 10 月 17 日更新了 Chrome 浏览器。此后我无法在 Chrome 中看到在 Google Maps v3 Javascript 上绘制的多边形。在 IE 中,它运行得很好,在 Chrome 最新更新之前,它在 Chrome 上也运行得很好。

如果我需要进行任何修复才能在 Chrome 中显示,请告诉我。

以下代码用于创建半径环的多边形。 Json 对象被传递给该方法,并用于在谷歌地图的 mapInstance 上绘制多边形。

EDRV2.EDRMAPV3GOOGLEV3.Map.prototype.createPolylines = function(category, subcategory, polylineJSONObjects, showOnMap) {
var polylines = [];
var pts = null;
var rawPairs = null;
var rawLngLat = null;

try {
for (var i = 0; i < polylineJSONObjects.length; i++) {
var polygonType = null;

switch (category) {
case EDRV2.LIGHTBOX.INTERNAL.SiteCategoryTypes.CONTOUR:
polygonType = EDRV2.EDRMAPV3.EnumPolygonTypes.CONTOUR;
break;
case EDRV2.LIGHTBOX.INTERNAL.SiteCategoryTypes.RADIUSRING:
polygonType = EDRV2.EDRMAPV3.EnumPolygonTypes.RADIUSRING;
break;
case EDRV2.LIGHTBOX.INTERNAL.SiteCategoryTypes.QUICKSCREENQUADRANT:
polygonType = EDRV2.EDRMAPV3.EnumPolygonTypes.QUICKSCREENQUADRANT;
break;
}

polylines.push(new EDRV2.EDRMAPV3GOOGLEV3.Polyline(polygonType, this.mapInstance, polylineJSONObjects[i].coordinates, polylineJSONObjects[i].normalPolyAttributes, polylineJSONObjects[i].highlightPolyAttributes, polylineJSONObjects[i].normalPolyAttributes.mapLabelText));
}

var mapObjectCollection = this.mapObjectAddRange(category, subcategory, EDRV2.EDRMAPV3.EnumMapObjectTypes.POLYLINE, polylines);
mapObjectCollection.isActivated = true;

if (showOnMap == true) {
for (var j = 0; j < mapObjectCollection.mapObjects.length; j++) {
mapObjectCollection.mapObjects[j].setMap(this.mapInstance);
}
}
} catch (ex) {
throw new Error("Unable to create Polylines: " + ex.message);
}
};

EDRV2.EDRMAPV3GOOGLEV3.Polyline = function (polyType, googleMap, dvgCoordinatesString, normalPolyAttributes, highlightPolyAttributes, labelText) {
// Constructor
if (this instanceof EDRV2.EDRMAPV3GOOGLEV3.Polyline) {
try {
// inheritance
google.maps.Polyline.apply(this, arguments);
this.base = google.maps.Polyline.prototype;

var pts = null;
var rawPairs = null;
var rawLngLat = null;

// validate map
if ((typeof (googleMap) == 'undefined') || (googleMap == null)) throw new Error('Missing or invalid googleMap.');
if (!(googleMap instanceof google.maps.Map)) throw new Error('googleMap is not of google.maps.Map type.');

// validate coordinates
if ((typeof (dvgCoordinatesString) == 'undefined') || (dvgCoordinatesString == null)) throw new Error('Missing or invalid polyline coordinates.');

dvgCoordinatesString = EDRV2.trim(dvgCoordinatesString);
if (dvgCoordinatesString == '') throw new Error('Missing or invalid polyline coordinates.');

// Code to convert DVG coordinates to Google Map LatLng corodinates.
pts = new Array;
rawPairs = dvgCoordinatesString.split('|');

for (var i = 0; i < rawPairs.length; i++) {
rawLngLat = (rawPairs[i]).split(',');
if ((rawLngLat[0] != '') && (rawLngLat[1] != '')) { pts.push(new google.maps.LatLng(rawLngLat[1], rawLngLat[0])); }
}

// Now initialize all properties.
this.polyType = polyType;
this.googleMap = googleMap;
this.normalPolyOptions = this.convertEdrPolyAttributesToGooglePolylineOptions(normalPolyAttributes);
this.highlightPolyOptions = this.convertEdrPolyAttributesToGooglePolylineOptions(highlightPolyAttributes);
this.labelText = labelText;

// Call setPaths to define the paths of the polyline and then convert normalPolyAttributes to Google Polyline Options.
this.setPath(pts);

if ((typeof (this.normalPolyOptions) != 'undefined') && (this.normalPolyOptions != null)) {
this.setOptions(this.normalPolyOptions);
}

switch (this.polyType) {
case EDRV2.EDRMAPV3.EnumPolygonTypes.CONTOUR:
google.maps.event.addListener(this, 'mouseover', this.onMouseOver);
google.maps.event.addListener(this, 'mouseout', this.onMouseOut);
google.maps.event.addListener(this, 'click', function (e) { EDRV2.EventCollector.fire({ type: EDRV2.EDRMAPV3.EnumEventNames.EDRMAPV3_CONTOUR_POLYLINECLICK, clickLatLng: e.latLng }); });
break;
}

this.createLabels(labelText);
this.isUsable = true;
}
catch (ex) {
this.isUsable = false;
this.errorMessage = 'Unable to create Polyline object: ' + ex.message;
}
}
else { return new EDRV2.EDRMAPV3GOOGLEV3.Polyline(polyType, googleMap, dvgCoordinatesString, normalPolyAttributes, highlightPolyAttributes, labelText); }

};

最佳答案

我遇到了这个问题。谢谢大家。只是想分享一下,因为这是新 Chrome 更新后发生的事情。

google.maps.Polyline.apply(this,arguments); 在 Chrome 中发生故障并给出只读异常。我删除了“应用”并使用了“调用”,它起作用了。这意味着 Chrome 正在破坏 Polyline 的应用。

google.maps.Polyline.call(this, 参数);

关于javascript - Chrome 更新 38.0.2125.104 m 后,Google Map API v3 不显示多边形,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26468023/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com