使用基本键与Bing Map Silverlight的结果不一致

使用基本键与Bing Map Silverlight的结果不一致,silverlight,dynamics-crm-2011,bing-api,bing-maps,Silverlight,Dynamics Crm 2011,Bing Api,Bing Maps,嗨,我用了下面的代码,但有时我没有得到图钉,我用的是基本的关键可以任何人请建议我 public MainPage() { InitializeComponent(); Geocode("8800 Lyra Avenue, Columbus, OH 43240", 1); Geocode("2137 Birchwood Dr, Redmond,WA 78214,U.S.", 1); Geocode("Santa Cru

嗨,我用了下面的代码,但有时我没有得到图钉,我用的是基本的关键可以任何人请建议我

    public MainPage()
    {
        InitializeComponent();
        Geocode("8800 Lyra Avenue, Columbus, OH 43240", 1);
        Geocode("2137 Birchwood Dr, Redmond,WA 78214,U.S.", 1);
        Geocode("Santa Cruz, Duval Co., TX", 1);
    }
     private void Geocode(string address, int waypointIndex)
    {
        PlatformServices.GeocodeServiceClient geocodingService = new PlatformServices.GeocodeServiceClient("BasicHttpBinding_IGeocodeService");
        geocodingService.GeocodeCompleted += new EventHandler<TestSL.PlatformServices.GeocodeCompletedEventArgs>(geocodingService_GeocodeCompleted);

        PlatformServices.GeocodeRequest request = new PlatformServices.GeocodeRequest();
        request.Credentials = new TestSL.PlatformServices.Credentials();
        request.Credentials.ApplicationId = ((Microsoft.Maps.MapControl.ClientTokenCredentialsProvider)(MyMap.CredentialsProvider)).Token;
        request.Query = address;

        geocodingService.GeocodeAsync(request, waypointIndex);
    }
    public void geocodingService_GeocodeCompleted(object sender, TestSL.PlatformServices.GeocodeCompletedEventArgs e)
    {
        MapLayer myMapLayer = new MapLayer();
        MyMap.Children.Add(myMapLayer);
        // create a location collection class
        LocationCollection myLocationColl = new LocationCollection();
        var geoResult = (from r in e.Result.Results
                         orderby (int)r.Confidence ascending
                         select r).FirstOrDefault();
        if (geoResult != null)
        {

            Pushpin myPushPin = new Pushpin();
            // set it to first found location
            myPushPin.Location = new Microsoft.Maps.MapControl.Location(geoResult.Locations[0].Latitude, geoResult.Locations[0].Longitude);
            ToolTipService.SetToolTip(myPushPin, geoResult.DisplayName);
            // add it to location collection
            // which would be used to set the map's bound
            myLocationColl.Add(myPushPin.Location);
            // Add the drawn point to the route layer.                   
            myMapLayer.Children.Add(myPushPin);
        }
    }
public主页()
{
初始化组件();
地理编码(“俄亥俄州哥伦布市莱拉大道8800号,邮编43240”,1);
地理编码(“美国华盛顿州雷德蒙德伯奇伍德博士2137号,邮编78214”,1);
地理编码(“德克萨斯州杜瓦尔公司圣克鲁斯”,1);
}
专用void地理代码(字符串地址,int waypointIndex)
{
PlatformServices.GeocodeServiceClient geocodingService=新的PlatformServices.GeocodeServiceClient(“BasicHttpBinding_IGeocodeService”);
geocodingService.GeocodeCompleted+=新事件处理程序(geocodingService\u GeocodeCompleted);
PlatformServices.GeocodeRequest request=新的PlatformServices.GeocodeRequest();
request.Credentials=newtestsl.PlatformServices.Credentials();
request.Credentials.ApplicationId=((Microsoft.Maps.MapControl.ClientTokenCredentialsProvider)(MyMap.CredentialsProvider)).Token;
request.Query=地址;
geocodingService.GeocodeAsync(请求、航路点索引);
}
public void geocodingService_GeocodeCompleted(对象发送方,TestSL.PlatformServices.GeocodeCompletedEventArgs e)
{
MapLayer myMapLayer=新的MapLayer();
MyMap.Children.Add(myMapLayer);
//创建位置集合类
LocationCollection myLocationColl=新LocationCollection();
var geoResult=(来自e.Result.Results中的r
orderby(int)r
选择r).FirstOrDefault();
如果(GeorgeSult!=null)
{
图钉myPushPin=新图钉();
//将其设置为第一个找到的位置
myPushPin.Location=new Microsoft.Maps.MapControl.Location(GeorgeSult.Locations[0]。纬度,GeorgeSult.Locations[0]。经度);
SetToolTip(myPushPin,geoResult.DisplayName);
//将其添加到位置集合
//这将用于设置地图的边界
myLocationColl.Add(我的图钉位置);
//将绘制的点添加到管线图层。
myMapLayer.Children.Add(myPushPin);
}
}

有时我得到两个图钉,有时我什么也没得到,有时我得到1或3。任何人都可以告诉我为什么会发生这种情况。

你应该提前对所有数据进行地理编码并存储坐标。尝试像这样动态地对一堆地址进行地理编码会增加应用程序生成的事务数。当使用基本密钥时,如果在短时间内发出一系列请求,则可以限制速率。当请求受速率限制时,会在响应的标头中添加一个标志来指示这一点。本页下半部分记录了这一点: