2017-08-25 28 views
0

我继承了一些与Bing Maps v6一起使用的代码,所以我现在试图在v8中重现功能。我做了以下初步尝试,但即使这似乎并不奏效。 (我试图按照https://social.technet.microsoft.com/wiki/contents/articles/34568.bing-maps-v6-3-to-v8-migration-guide.aspx以及我在网上找到的各种其他位,但是我在Bing地图上没有任何知识,所以我在显然很重要的方面犯了错误,因为这没有结果。很高兴为指导。创建html来调用Bing Maps

我省略低于我们的兵关键,但除此之外,这是我尝试使用的代码。

<!DOCTYPE html> 
<html> 
    <head> 
     <title>Title here</title> 
     <meta http-equiv='Content-Type' content='text/html; charset=utf-8'/> 
    </head> 
    <body>   
     <div id='myMap' style='width: 100vw; height: 100vh;'></div> 
     <script type='text/javascript'> 
       var map; 
       function loadMap() { 
        map = new Microsoft.Maps.Map(document.getElementById('myMap'), { 
         credentials: 'BingKeyOmittedHereForSecurityPurposes' 
        }); 
        map.Geocode('Jericho, VT', GeocodeCallback); 
       } 
       function GeocodeCallback(layer, results, places, hasMore, veErrorMessage) { 
       // no idea what should be here 
       }    
     </script> 
     <script type='text/javascript' 
     src='https://www.bing.com/api/maps/mapcontrol?callback=loadMap' async defer></script> 
    </body> 
</html> 

我将加入引脚和可能的方向,一旦我得到这个工作,但认为我应该得到花哨之前的基础工作。

回答

1

该地图没有地理编码功能,而是你hav e使用搜索模块。 Bing Maps V7及以上版本使用模块突出了其他功能。与V6相比,这样可以使页面负载轻得多,而V6的每一个可能的功能都塞满了单个下载的文件。

在任何情况下,这里都是如何在V8中进行地理编码的示例。 https://github.com/Microsoft/BingMapsV8CodeSamples/blob/master/Samples/Search/Geocode.html

这里有一些资源,帮助您进行迁移:

Bing Maps V8 code samples

Bing Maps V6.3 to V8 Migration Guide