0

我正在使用 html5 开发 Windows 8 应用程序,现在我被地图困住了,该地图将找到用户位置更多的工作,我有这个项目的最后期限

地图.html

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

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

    <!-- WinJS references -->
    <link href="//Microsoft.WinJS.1.0/css/ui-dark.css" rel="stylesheet" />
    <script src="//Microsoft.WinJS.1.0/js/base.js"></script>
    <script src="//Microsoft.WinJS.1.0/js/ui.js"></script>

    <!-- BingMapsJSIntro references -->
    <link href="/css/default.css" rel="stylesheet" />
    <script src="/js/default.js"></script>

    <!-- Bing Maps references -->
    <script type="text/javascript"
            src="ms-appx:///Bing.Maps.JavaScript//js/veapicore.js"></script>

    <!-- Our Bing Maps JavaScript Code -->
    <script src="/js/bing.js"></script>
</head>
<body>
     <div id="myMap"></div>

</body>
</html>

bing.js

    var map;

function showMap(position) {
    var latitude = position.coords.latitude;
    var longitude = position.coords.longitude;

    var map = new Microsoft.Maps.Map($("mymap")[0],
    {
        credentials: "MYBINGMAPCODE",
        center: new Microsoft.Maps.Location(latitude, longitude),
        mapTypeId: Microsoft.Maps.MapTypeId.road,
        zoom: 10
    });

    var center = map.getCenter();
    var pin = new Microsoft.Maps.Pushpin(center, { width: 50, height: 50, draggable: false });
    map.entities.push(pin);
}

//Initialization logic for loading the map control
(function () {
    function initialize() {
        Microsoft.Maps.loadModule('Microsoft.Maps.Map', { callback: GetMap });
    }

    document.addEventListener("DOMContentLoaded", initialize, false);
})();
4

1 回答 1

0

您提供的代码中不存在您的模块回调方法“ GetMap ”。

Microsoft.Maps.loadModule('Microsoft.Maps.Map', { callback: GetMap });

你需要类似...

function GetMap ()
{
   var mapOptions = { credentials:"<Insert Your Bing Maps Key Here>" }
   var map = new Microsoft.Maps.Map(document.getElementById("myMap"), mapOptions );
} 
于 2013-07-06T05:53:02.420 回答