public Job_Map() { InitializeComponent(); start = (App.Current as App).CurrentLocation; AGeoCoordinateWatcher amapGeoCoordinateWatcher = new AGeoCoordinateWatcher(); amapGeoCoordinateWatcher.PositionChanged += amapGeoCoordinateWatcher_PositionChanged; amapGeoCoordinateWatcher.StatusChanged += amapGeoCoordinateWatcher_StatusChanged; amapGeoCoordinateWatcher.Start(); map.Center = start; Messenger.Default.Register<MLngLat>(this,"mLngLat", (mLngLat) => { end = mLngLat; if (start != null) { map.Children.Add(new MMarker() { LngLat = start, IsEditable = true, IconURL = "/Resource/Image/WVGA/bus_start_pic.jpg", Anchor = new Point(0.5, 1) }); } if (end != null) { map.Children.Add(new MMarker() { LngLat = end, IconURL = "/Resource/Image/WVGA/bus_end_pic.jpg", Anchor = new Point(0.5, 1) }); } RouteSearchWithOption(); }); }
void map_Tap(object sender, System.Windows.Input.GestureEventArgs e) { Point p = e.GetPosition(map);//获得在map容器的像素坐标 if (start == null) { start = map.FromScreenPixelToLngLat(p);//确定起点 startText.Text = start.ToString(); map.Children.Add(new MMarker() { LngLat = start, IsEditable = true, IconURL = "/bus_start_pic.jpg", Anchor = new Point(0.5, 1) }); } else if (end == null) { end = map.FromScreenPixelToLngLat(p);//确定终点 endText.Text = start.ToString(); map.Children.Add(new MMarker() { LngLat = end, IconURL = "/bus_end_pic.jpg", Anchor = new Point(0.5, 1) }); } }
void map_Tap(object sender, System.Windows.Input.GestureEventArgs e) { Point p = e.GetPosition(map); //获得在map容器的像素坐标 MLngLat xy = map.FromScreenPixelToLngLat(p); //确定经纬度 x = xy.LngX; y = xy.LatY; ReGeoCodeToAddressWithOption(); map.Tap -= new EventHandler <System.Windows.Input.GestureEventArgs>(map_Tap); }
public Job_Map() { InitializeComponent(); start = (App.Current as App).CurrentLocation; AGeoCoordinateWatcher amapGeoCoordinateWatcher = new AGeoCoordinateWatcher(); amapGeoCoordinateWatcher.PositionChanged += amapGeoCoordinateWatcher_PositionChanged; amapGeoCoordinateWatcher.StatusChanged += amapGeoCoordinateWatcher_StatusChanged; amapGeoCoordinateWatcher.Start(); map.Center = start; Messenger.Default.Register <MLngLat>(this, "mLngLat", (mLngLat) => { end = mLngLat; if (start != null) { map.Children.Add(new MMarker() { LngLat = start, IsEditable = true, IconURL = "/Resource/Image/WVGA/bus_start_pic.jpg", Anchor = new Point(0.5, 1) }); } if (end != null) { map.Children.Add(new MMarker() { LngLat = end, IconURL = "/Resource/Image/WVGA/bus_end_pic.jpg", Anchor = new Point(0.5, 1) }); } RouteSearchWithOption(); }); }
void amapGeoCoordinateWatcher_PositionChanged(object sender, AGeoPositionChangedEventArgs e) { start = e.LngLat; (App.Current as App).CurrentLocation = start; }
private async void SearchWalking(MLngLat stat, MLngLat end) { try { AMapRouteResults rr = await AMapNavigationSearch.WalkingNavigation(stat.LngX, stat.LatY, end.LngX, end.LatY); if (rr.Erro != null) { return; } if (rr.Route != null && rr.Count != 0) { AMapRoute route = rr.Route; List<AMapPath> paths = route.Paths.ToList(); MLngLatCollection lnglats = new MLngLatCollection(); List<MOverlay> list = new List<MOverlay>(); List<string> walkSteps = new List<string>(); foreach (AMapPath path in paths) { //画路线 List<AMapStep> steps = path.Steps.ToList(); foreach (AMapStep st in steps) { Debug.WriteLine(st.Instruction); walkSteps.Add(st.Instruction); lnglats = latLagsFromString(st.Polyline); MPolyline walkPolyling = new MPolyline(lnglats); walkPolyling.LineThickness = 6; walkPolyling.LineColor = Colors.Green; mapWalkingLayer.Children.Add(walkPolyling); list.Add(walkPolyling); } } map.SetFitview(list); //TODO: tip walkSteps } } catch (Exception ex) { Debug.WriteLine("SearchWalking:" + ex.Message); } }
private async void HoldSearchGeoToAddress(MLngLat mlnglat) { try { AMapReGeoCodeResult rgrc = await AMapReGeoCodeSearch.GeoCodeToAddress(mlnglat.LngX, mlnglat.LatY); mapToiletLayer.Children.Add(new MMarker() { LngLat = mlnglat, IconURL = "Images/AZURE.png", TipFrameworkElement = new MTip() { ContentText = rgrc.ReGeoCode.Formatted_address } }); } catch (Exception ex) { Debug.WriteLine("HoldSearchGeoToAddress:" + ex.Message); } }
/// <summary> /// 逆地理编码 /// </summary> /// <param name="mlnglat"></param> private async void SearchGeoToAddress(MLngLat mlnglat) { try { AMapReGeoCodeResult rgrc = await AMapReGeoCodeSearch.GeoCodeToAddress(mlnglat.LngX, mlnglat.LatY); if (rgrc.Erro != null) { return; } if (rgrc.ReGeoCode != null) { myLoaction.TipFrameworkElement = new MTip() { ContentText = rgrc.ReGeoCode.Formatted_address }; } } catch (Exception ex) { Debug.WriteLine("SearchGeoToAddress:" + ex.Message); } }
void tip_TapNavigation(object sender, TapNavigationEventArgs e) { try { this.Dispatcher.BeginInvoke(() => { MLngLat end = new MLngLat(e.MarkerAMapPOI.Location.Lon, e.MarkerAMapPOI.Location.Lat); mapWalkingLayer.Children.Clear(); SearchWalking(myLoaction.LngLat, end); }); } catch (Exception ex) { Debug.WriteLine("tip_TapNavigation:" + ex.Message); } }
/// <summary> /// 搜索厕所 /// </summary> /// <param name="mlnglat"></param> /// <param name="radios"></param> private async void SearchKeyWordToilet(MLngLat mlnglat, uint radios) { //AMapFilterOption option=new AMapFilterOption (); //option.Groupbuy=false; //option.Discount=false; try { AMapPOIResults pois = await AMapPOISearch.POIAround(mlnglat.LngX, mlnglat.LatY, "公厕|厕所|洗手间|麦当劳|肯德基|必胜客|德克士", "", false, false, radios, 0, 100, 1, Extensions.All); this.Dispatcher.BeginInvoke(() => { if (pois.Erro != null) { return; } if (pois.POIList == null) { } List<MOverlay> list = new List<MOverlay>(); foreach (AMapPOI poi in pois.POIList.ToList()) { MMarker Marker; mapToiletLayer.Children.Add(Marker = new MMarker() { LngLat = new Com.AMap.Maps.Api.BaseTypes.MLngLat(poi.Location.Lon, poi.Location.Lat), Anchor = new Point(0.5, 1), IconURL = "Images/54x74.png", TipFrameworkElement = tip = new ToiletTip() { Text = poi.Name, MarkerAMapPOI = poi }, }); tip.TapNavigation += tip_TapNavigation; list.Add(Marker); Debug.WriteLine(poi.Name.ToString()); //TODO:gridNavigation } map.SetFitview(list); }); } catch (Exception ex) { Debug.WriteLine("SearchKeyWordToilet:" + ex.Message); } }