Bing Maps v8 migration: Cannot read property road of undefined Error when refresh page.


we using scala , angularjs.

bing map load in head section (main.scala.html).

<!-- bing maps library (must loaded in head section) -->
<script type="text/javascript" src="https://www.bing.com/api/maps/mapcontrol"></script>

map = new $window.microsoft.maps.map(document.getelementbyid('mapdiv'), {
credentials: 'my credential',
maptypeid: microsoft.maps.maptypeid.road,
animate: true,
showdashboard: !$scope.readonly,
useinertia: false,
enablesearchlogo: false,
enableclickablelogo: false,
showcopyright: false
});

when refresh map in mapcontroller.js. typeerror: cannot read property 'road' of undefined display

the problem won't exist if load page normally.

problem not exist in v7.





i highly recommend using callback option of map control. map control loads lot of dependency libraries asynchronously resulting in map load code being fired before map control script loaded. recommend loading map script last. reason when map script cached, callback function fire right away , loadmap function may not yet available. example:

<script> var map;  function loadmap(){     map = new $window.microsoft.maps.map(document.getelementbyid('mapdiv'), {         credentials: 'my credential',         maptypeid: microsoft.maps.maptypeid.road,         animate: true,         showdashboard: !$scope.readonly,         useinertia: false,         enablesearchlogo: false,         enableclickablelogo: false,         showcopyright: false     }); } </script>  <script type="text/javascript" src="https://www.bing.com/api/maps/mapcontrol?callback=loadmap"></script>


[blog] [twitter] [linkedin]




Bing Maps  >  Bing Maps General



Comments

Popular posts from this blog

Azure DocumentDB Owner resource does not exist

job syspolicy_purge_history job fail in sqlserver 2008

Trying to register with public marketplace error with 'Get-AzureStackStampInformation'