/// <summary> /// 注意:要开启定位权限 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private async void LocateClick(object sender, RoutedEventArgs e) { var aMapGeolocator = new AMapGeolocator(); LngLat myLngLat = await aMapGeolocator.GetLngLatAsync(); var icon = new AMapIcon { Location = myLngLat }; baseLayer.Add(icon); await aMapControl.TrySetViewAsync(myLngLat, 15, 0, 0, AMapAnimationKind.Default); }
private async void IdSearch_OnClick(object sender, RoutedEventArgs e) { baselayer.Clear(); aMapControl.HideInfoWindow(); string id = "B000A07060"; AMapPOIResults results = await AMapPOISearch.POIID(id); if (results.Erro == null) { if (results.POIList == null || results.POIList.Count == 0) { Debug.WriteLine("无查询结果"); return; } foreach (AMapPOI item in results.POIList) { var icon = new AMapIcon { Location = new LngLat(item.Location.Lon, item.Location.Lat) }; icon.Tapped += icon_Tapped; icon.Data = item.Address; await baselayer.Add(icon); } aMapControl.TrySetViewAsync( new LngLat(results.POIList[0].Location.Lon, results.POIList[0].Location.Lat), null, null, null, AMapAnimationKind.Default); } else { Debug.WriteLine(results.Erro.Message); } }
private void ToBeijing(object sender, RoutedEventArgs e) { aMapControl.TrySetViewAsync(beijing, 11, 45, 15, AMapAnimationKind.Default); }
private async void aMapControl_MapTapped(AMapControl sender, AMapInputEventArgs args) { AMapReGeoCodeResults results = await AMapReGeoCodeSearch.GeoCodeToAddress(args.Location.Longitude, args.Location.Latitude, 500, "", Extensions.All); //todo 一下坐标存在问题 //var error1 = new LngLat(116.251101, 39.836455); //AMapReGeoCodeResults results = await AMapReGeoCodeSearch.GeoCodeToAddress(error1.Longitude, error1.Latitude, 500, "", Extensions.All); if (results.Erro == null) { if (results.ReGeoCode == null) { addressOutputTextblock.Text = "返回为null"; return; } AMapReGeoCode regeocode = results.ReGeoCode; Debug.WriteLine(regeocode.Address_component); Debug.WriteLine(regeocode.Formatted_address); Debug.WriteLine(regeocode.Pois); List <AMapPOI> pois = regeocode.Pois.ToList(); //POI信息点 foreach (AMapPOI poi in pois) { Debug.WriteLine(poi.Address); } Debug.WriteLine(regeocode.Roadinters); Debug.WriteLine(regeocode.Roadslist); AMapAddressComponent addressComponent = regeocode.Address_component; //todo building //Debug.WriteLine(addressComponent.Building); Debug.WriteLine(addressComponent.City); Debug.WriteLine(addressComponent.District); //todo 邻居 //Debug.WriteLine(addressComponent.Neighborhood); Debug.WriteLine(addressComponent.Province); Debug.WriteLine(addressComponent.Stree_number); Debug.WriteLine(addressComponent.Township); AMapStreetNumber streetNumber = addressComponent.Stree_number; Debug.WriteLine(streetNumber.Direction); Debug.WriteLine(streetNumber.Distance); Debug.WriteLine(streetNumber.Location.Lat); Debug.WriteLine(streetNumber.Location.Lon); Debug.WriteLine(streetNumber.Number); Debug.WriteLine(streetNumber.Street); addressOutputTextblock.Text = regeocode.Formatted_address; aMapControl.TrySetViewAsync(args.Location); } else { addressOutputTextblock.Text = results.Erro.Message; } }