2017-08-25 31 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