Bing映射v8没有为IE11加载

时间:2017-01-01 15:53:54

标签: javascript bing-maps

我正在做一个非常标准的地图加载,例如:

 map = new Microsoft.Maps.Map(document.getElementById('map_canvas'));

在Chrome中它运行正常,但在IE11中,我在地图代码中遇到异常:

0x800a01b6 - JavaScript运行时错误:对象不支持属性或方法' matchMedia'

Bing地图代码中的行是:

return window.matchMedia("(-ms-high-contrast:active)").matches

定义了窗口变量,但如果我检查它,则matchMedia未定义。

整个堆栈跟踪是:

Unhandled exception at line 1, column 9149 in https://www.bing.com/rms/MapCoreBundle/jc,nj/81a88ae6/9adb7eaf.js?bu=rms+answers+MapsSDK+AnonymousBegin*MapCore.en*MapCoreBegin*LabelOptions*LocalStorageCache*Gimme*GimmeWrapper*evPromise*ExternalPromise*StaticPromise*CookiesHelper*LruCache*Point*Rectangle*NAARectangle*ResourceManager*Units*Anchor*Size*Binding*ChangeMagnitude*EventBinding*Observable*ObservableObject*ObservableObjectChangedArgs*ObservableCollection*Debug*DelayLoadedObject*JSEvent*Dispatcher*WorkDispatcher*Iterator*ElementSizeHelper*GimmeExt*GimmeTransition*Helper*PerfState*ClientPerf*LoggingWrapper*LoggerConstants*Network*ThrottledEventInvoker*ObjectPool*StaticObjectPool*FixedSizeObjectPool*OrderedDictionary*PooledImage*Url*MapCoreMiddle*AltitudeReference*TransformCurve*GraphType*CurveKey*Curve*Color*CurveVector4*CurveColor*Vector4*CurveTangent*DiscreteRange*DiscreteRangeCollectionSpline*MapLayer*AutoScaling*PointLabelPlacementPreference*PolygonFillPreference*VerticalAlignment*CopyrightProvider*CopyrightProviderService*EntityState*MinZoomFraming*GeometryType*HitTestability*HorizontalAlignment*MapModeType*ViewChangeCause*MapFrameManager*LayerFrameManager*GoalCounter*FrameEventAggregator*DataMonitor*MapFrameData*LayerFrameData*Clipper*CompositePrimitiveSet*DataLoader*Differ*FixedPrimitiveSet*PrimitiveSubset*Overlay*OverlayAlignment*ImageryMapLayer*SimpleSceneContributor*VectorMapLayer*BasicMapAnimation*MapViewAnimator*BoundsAccumulator*CombinedLayerCollection*ConstrainViewArgs*LatLonCrs*LocationRect*Matrix2D*MapInstrumentationManager*Map*MapHelper*MapMath*MapLocation*MapType*MapTypeChangeArgs*MapTypeCollection*MapTypeId*MapView*MapEventForPrimitiveOverlay*MapQuadrant*PrimitiveOverlayHelper*OverlayBehavior*GeometryGeneralizer*SimplePointPrimitive*SimpleLinePrimitive*SimpleAreaPrimitive*MoveableSimplePointPrimitive*TargetViewChangeArgs*VectorMath*ViewChangeArgs*ZoomLevel*ZoomAroundLocationAnimator*ZoomEventArgs*OverviewMapMode*MapAuthentication*PublicApi*InternalApi*AnonymousEnd

0x800a01b6 - JavaScript runtime error: Object doesn't support property or method 'matchMedia'

感谢您的帮助!

1 个答案:

答案 0 :(得分:4)

Internet Explorer 11 should support matchMedia。因此,最可能的原因是文档正在non full standard mode中解析。可能是因为您未在HTML顶部指定doctype,例如:

<!DOCTYPE html>

作为最顶层的HTML行。

另一种可能性是您声明浏览器应使用兼容模式,例如使用http-equiv="X-UA-Compatible"元标记。如果此标记存在,请尝试删除它。如果它不存在,请尝试添加

<meta http-equiv="X-UA-Compatible" content="IE=Edge">

确保IE正在使用最新模式。 Read more here.