我在2014年10月17日更新了Chrome浏览器。在此之后,我无法在Chrome上的Google Maps v3 Javascript上看到多边形。在IE中它完美运行,在Chrome最新更新之前,它在Chrome上运行良好。
如果我需要在Chrome中显示任何修复程序,请与我们联系。
以下代码用于创建半径环的多边形。 Json Object被传递给方法,它被用于在google Map的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); }
};
答案 0 :(得分:1)
我遇到了这个问题。谢谢大家。只是想分享它,因为这是新的Chrome更新后发生的事情。
google.maps.Polyline.apply(this, arguments);
在Chrome中出现故障,并提供了一个只读异常。我删除了'apply'并使用了'call'并且它有效。这意味着Chrome正在申请Polyline。
google.maps.Polyline.call(this, arguments);