示例#1
0
        private static void OnGeocodeResultChanged(Map map, BingMapsService.GeocodeResult oldValue, BingMapsService.GeocodeResult newValue)
        {
            Location location = newValue.Locations.Select(x => new Location(x.Latitude, x.Longitude)).First();
            Pushpin  pin      = new Pushpin();

            pin.Location = location;
            pin.ToolTip  = newValue.Address.FormattedAddress;
            var locationLayer = GetGeocodeResultLayer(map);

            if (locationLayer == null)
            {
                locationLayer = new MapLayer();
                SetGeocodeResultLayer(map, locationLayer);
            }
            locationLayer.Children.Clear();
            locationLayer.Children.Add(pin);
            map.SetView(location, map.ZoomLevel);
        }
        public void GeocodeAddress(string address)
        {
            using (BingMapsService.GeocodeServiceClient client = new BingMapsService.GeocodeServiceClient("CustomBinding_IGeocodeService"))
            {
                client.GeocodeCompleted += (o, e) =>
                {
                    if (e.Error == null)
                    {
                        if (e.Result.Results.Length > 0)
                            GeocodeResult = e.Result.Results[0];
                    }
                };

                BingMapsService.GeocodeRequest request = new BingMapsService.GeocodeRequest();
                request.Credentials = new Credentials() { ApplicationId = "aOyFCmxtUgVSoHjkiyg~BGHaMho-ZThx5-KH-3X2kg~AgxaPsUOnRYhaxfAC6W8Wpx8pd-ZIQI17FRkPkd9llQm4I5-5XpkUYDOcGXqc_x5" };
                request.Query = address;
                client.GeocodeAsync(request);
            }
        }
        public void GeocodeAddress(string address)
        {
            using (BingMapsService.GeocodeServiceClient client = new BingMapsService.GeocodeServiceClient("CustomBinding_IGeocodeService"))
            {
                client.GeocodeCompleted += (o, e) =>
                {
                    if (e.Error == null)
                    {
                        if (e.Result.Results.Length > 0)
                        {
                            GeocodeResult = e.Result.Results[0];
                        }
                    }
                };

                BingMapsService.GeocodeRequest request = new BingMapsService.GeocodeRequest();
                request.Credentials = new Credentials()
                {
                    ApplicationId = "aOyFCmxtUgVSoHjkiyg~BGHaMho-ZThx5-KH-3X2kg~AgxaPsUOnRYhaxfAC6W8Wpx8pd-ZIQI17FRkPkd9llQm4I5-5XpkUYDOcGXqc_x5"
                };
                request.Query = address;
                client.GeocodeAsync(request);
            }
        }
 public static void SetGeocodeResult(Map target, BingMapsService.GeocodeResult value)
 {
     target.SetValue(GeocodeResultProperty, value);
 }