bing 地图 windows phone 8.1

bing maps in windows phone 8.1

正在开发一个使用地图的应用程序,并且正在使用 html、javascript 进行开发,我发现 windows 商店应用程序有一个扩展可以使用 bing 地图,但 windows phone 8.1 javascript 应用程序开发不支持它。所以我侵入了 RT 的张力并添加到我的项目中,我得到的唯一错误是 Windows.ApplicationModel.Resource.core.ResourceManager 已被弃用。而且我知道其他脚本在地图加载之前正在加载。但我仍然找不到他的解决方案。这是我的代码。

default.html

    <!DOCTYPE html>
    <html>
     <head>
       <meta charset="utf-8" />
        <title>homePage</title>

<!-- WinJS references -->
<script src="//Microsoft.Phone.WinJS.2.1/js/base.js"></script>
<script src="//Microsoft.Phone.WinJS.2.1/js/ui.js"></script>

<link href="/css/default.css" rel="stylesheet" />
<link href="/pages/home/home.css" rel="stylesheet" />
<script src="/pages/home/home.js"></script>

<!-- bing map api-->
<script type="text/javascript" src="/js/bing/veapicore.js"></script>
<script type="text/javascript" src="/js/bing/veapiModules.js"></script>
<link href="/css/mapcontrol.css" rel="stylesheet" />

<!--<script type="text/javascript"
        src="http://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=7.0">
</script>-->

<!-- bing map controls-->
<script src="/js/MapControls.js"></script>
 </head>
<body>
<!-- The content that will be loaded and displayed. -->
<div class="fragment homepage">
    <header aria-label="Header content" role="banner">
        <h1 class="titlearea win-type-ellipsis">
            <span class="pagetitle">Native</span>
        </h1>
    </header>
    <section aria-label="Main content" role="main" style="overflow:auto;">
        <div style="float:left; margin: 10px 10px 10px 10px;">
            <input type="button" value="Get My Location" onclick="GetMyLocation();" />
            <input type="text" id="txtStart" placeholder="Source" maxlength="50" />
            <input type="text" id="txtEnd" placeholder="Destination" maxlength="50" />
            <input type="button" value="Create Route" onclick="GetRoute();" />
        </div>
       <div id="mapcontainer" style="height:150px;width:150px;"></div>
       <div id='itineraryDiv' style="position:relative; width:40%; height:90%; float: right; overflow:auto; font-family:Verdana, Arial"></div> 
    </section>
</div>

mapcontrol.js

    (function () {
     function initialize() {
      Microsoft.Maps.loadModule('Microsoft.Maps.Map', { callback: GetMap });
     }
      document.addEventListener("DOMContentLoaded", initialize, false);
     })();


      var map, searchManager, directionsManager, loc = null;

      function GetMap() {
       var mapOptions =
       {
        credentials: "bing map key",
        mapTypeId: Microsoft.Maps.MapTypeId.road
       };
       map = new Microsoft.Maps.Map(document.getElementById("mapcontainer"),       mapOptions);
        }

        function GetMyLocation() {
           var geolocator = new Windows.Devices.Geolocation.Geolocator();
           geolocator.getGeopositionAsync().then(function (loc) {
           var mapCenter = map.getCenter();
           mapCenter.latitude = loc.coordinate.latitude;
           mapCenter.longitude = loc.coordinate.longitude;
           map.setView({ center: mapCenter, zoom: 12 });

            var loc = new Microsoft.Maps.Location(loc.coordinate.latitude, loc.coordinate.longitude);
            var pushPin = new Microsoft.Maps.Pushpin(loc);
            map.entities.push(pushPin);
           });  
          }

       function geocodeCallback(response, userData) {
          if (response &&
               response.results &&
             response.results.length > 0) {
             var r = response.results[0];
             var l = new Microsoft.Maps.Location(r.location.latitude,                  r.location.longitude);

    //Display result on map       
    var p = new Microsoft.Maps.Pushpin(l);
    map.entities.push(p);

    //Zoom to result
    map.setView({ center: l, zoom: 15 });
     } else {
    ShowMessage("Geocode Response", "Not results found.");
     }
    }

    function GetRoute() {
     ClearMap();

    if (directionsManager) {
       directionsManager.setRequestOptions({ routeMode:    Microsoft.Maps.Directions.RouteMode.driving });

    var startWaypoint = new Microsoft.Maps.Directions.Waypoint(
        { address: document.getElementById('txtStart').value });

    var endWaypoint = new Microsoft.Maps.Directions.Waypoint(
        { address: document.getElementById('txtEnd').value });

    directionsManager.addWaypoint(startWaypoint);
    directionsManager.addWaypoint(endWaypoint);

    directionsManager.setRenderOptions({ itineraryContainer:   document.getElementById('itineraryDiv') });
    directionsManager.calculateDirections();
} else {
    Microsoft.Maps.loadModule('Microsoft.Maps.Directions', {
        callback: function () {
            directionsManager = new Microsoft.Maps.Directions.DirectionsManager(map);

            GetRoute();
            }
        });
     }
 }

   function ClearMap() {
      map.entities.clear();

      if (directionsManager) {
       directionsManager.resetDirections();
     }
    }

   function geocodeError(request) {
    ShowMessage("Geocode Error", "Unable to Geocode request.");
}

  function ShowMessage(title, msg) {
     var m = new Windows.UI.Popups.MessageDialog(title, msg);
    m.showAsync();
 }

我得到的错误是。

方法 Windows.ApplicationModel.Resources.Core.ResourceManager.get_DefaultContext 已被弃用。对于 Windows Phone 'OSVersion' 之后的版本,DefaultContext 可能会更改或不可用(待定)。相反,使用 ResourceContext.GetForCurrentView.

如果有人能弄明白,那将非常有帮助。提前致谢。

使用在线 URL 到 Bing 地图 V7 或 v8,而不是来自 Windows 8 API 的 JS 文件。请注意 Windows 8 API 在 Windows 10 中已弃用。