Exemplo n.º 1
0
        /// <summary>
        /// MarkerTIP上添加自定义容器
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void AddCustomTipOnMarker(object sender, RoutedEventArgs e)
        {
            //自定义容器
            CustomOverlayControl coo = new CustomOverlayControl();
            AMarker marker           = new AMarker();

            marker.LngLat = map.Center;
            marker.TipFrameworkElement = coo;
            map.Children.Add(marker);
            marker.OpenTip();
        }
Exemplo n.º 2
0
        /// <summary>
        /// 在Marker上添加信息窗口
        /// </summary>
        public void AddTipOnMarker(object sender, RoutedEventArgs e)
        {
            ATip tip = new ATip();

            tip.Title       = "我是标题";
            tip.ContentText = "我是内容";
            AMarker marker = new AMarker();

            marker.LngLat = map.Center;
            marker.TipFrameworkElement = tip;
            map.Children.Add(marker);
            marker.OpenTip();
        }
Exemplo n.º 3
0
        public MapView()
        {
            this.InitializeComponent();

            this.Output.Children.Add(rootPage.map);

            AMarker marker = new AMarker();

            marker.LngLat  = rootPage.CurrentLocation;
            marker.IconURI = new Uri("http://api.amap.com/webapi/static/Images/marker_sprite.png ");
            ATip tip = new ATip();

            tip.Title                  = "当前位置";
            tip.ContentText            = "Current Position";
            marker.TipFrameworkElement = tip;
            rootPage.map.Children.Add(marker);
            marker.OpenTip();

            if (rootPage.CurrentReminderStation != null)
            {
                this.GotoReminder.IsEnabled = true;
            }

            /*
             * if (rootPage.CurrentStation != null)
             * {
             *  foreach (StationFeature feature in rootPage.CurrentStation.response.resultSet.busLine.stationData.StationFeatures)
             *  {
             *      AMarker marker = new AMarker();
             *      marker.LngLat = new ALngLat(feature.longitude, feature.latitude);
             *      marker.IconURI = new Uri("http://api.amap.com/webapi/static/Images/marker_sprite.png ");
             *      ATip tip = new ATip();
             *      tip.Title = "站点";
             *      tip.ContentText = feature.caption;
             *      marker.TipFrameworkElement = tip;
             *      rootPage.map.Children.Add(marker);
             *      marker.OpenTip();
             *  }
             * }
             * */
        }
Exemplo n.º 4
0
        public MapView()
        {
            this.InitializeComponent();

            this.Output.Children.Add(rootPage.map);

            AMarker marker = new AMarker();
            marker.LngLat = rootPage.CurrentLocation;
            marker.IconURI = new Uri("http://api.amap.com/webapi/static/Images/marker_sprite.png ");
            ATip tip = new ATip();
            tip.Title = "当前位置";
            tip.ContentText = "Current Position";
            marker.TipFrameworkElement = tip;
            rootPage.map.Children.Add(marker);
            marker.OpenTip();

            if (rootPage.CurrentReminderStation != null)
            {
                this.GotoReminder.IsEnabled = true;
            }
    
            /*
            if (rootPage.CurrentStation != null)
            {
                foreach (StationFeature feature in rootPage.CurrentStation.response.resultSet.busLine.stationData.StationFeatures)
                {
                    AMarker marker = new AMarker();
                    marker.LngLat = new ALngLat(feature.longitude, feature.latitude);
                    marker.IconURI = new Uri("http://api.amap.com/webapi/static/Images/marker_sprite.png ");
                    ATip tip = new ATip();
                    tip.Title = "站点";
                    tip.ContentText = feature.caption;
                    marker.TipFrameworkElement = tip;
                    rootPage.map.Children.Add(marker);
                    marker.OpenTip();
                }
            }
             * */
        }
Exemplo n.º 5
0
        private async void GeoCodeTest()
        {
            GeoCodingOption rgo = new GeoCodingOption();

            rgo.Address = "北京市朝阳区望京阜通东大街方恒国际中心";
            GeoCodingResult rgcs = await GeoCode.AddressToGeoCodeWithOption(rgo);

            this.Dispatcher.RunAsync(CoreDispatcherPriority.High, () =>
            {
                if (rgcs.Erro == null && rgcs.GeoCodingList != null)
                {
                    IEnumerable <GeoPOI> pois = rgcs.GeoCodingList;
                    int i = 0;
                    foreach (GeoPOI poi in pois)
                    {
                        i++;
                        ATip tip                   = new ATip();
                        tip.Title                  = poi.Name;
                        tip.ContentText            = poi.Address;
                        AMarker marker             = new AMarker();
                        marker.LngLat              = new ALngLat(poi.X, poi.Y);
                        marker.TipFrameworkElement = tip;
                        map.Children.Add(marker);
                        marker.OpenTip();
                        map.SetZoomAndCenter(18, marker.LngLat);
                    }
                    Debug.WriteLine(rgcs);
                }
                else
                {
                    MessageDialog msd = new MessageDialog(rgcs.Erro.Message);
                    this.Dispatcher.RunAsync(CoreDispatcherPriority.Low, () =>
                    {
                        msd.ShowAsync();
                    });
                }
            });
        }
Exemplo n.º 6
0
        void ageol_PositionChanged(AGeolocator sender, APositionChangedEventArgs args)
        {
            this.Dispatcher.RunAsync(CoreDispatcherPriority.High, async() =>
            {
                CurrentLocation = args.LngLat;

                try
                {
                    //update current location
                    if (this.currentViewType != null && this.currentViewType == typeof(MapView))
                    {
                        AMarker marker             = new AMarker();
                        marker.LngLat              = this.CurrentLocation;
                        marker.IconURI             = new Uri("http://api.amap.com/webapi/static/Images/marker_sprite.png ");
                        ATip tip                   = new ATip();
                        tip.Title                  = "当前位置";
                        tip.ContentText            = "Current Position";
                        marker.TipFrameworkElement = tip;
                        this.map.Children.Clear();
                        this.map.Children.Add(marker);
                        marker.OpenTip();
                    }

                    if (DateTime.Now.ToFileTime() - lastUpdate.ToFileTime() < 30000000)
                    {
                        return;
                    }

                    //convert location to sogo location
                    string points = string.Format("{0},{1}", CurrentLocation.LngX, CurrentLocation.LatY);
                    string url    = SogoMapService.GetTranslationInfoURL(points);
                    HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, url);

                    HttpResponseMessage response = await httpClient.SendAsync(request,
                                                                              HttpCompletionOption.ResponseHeadersRead);

                    string result = "";
                    using (Stream responseStream = await response.Content.ReadAsStreamAsync())
                    {
                        int read             = 0;
                        byte[] responseBytes = new byte[1000];
                        do
                        {
                            read       = await responseStream.ReadAsync(responseBytes, 0, responseBytes.Length);
                            string tmp = System.Text.Encoding.GetEncoding("GBK").GetString(responseBytes, 0, read);
                            result    += tmp;
                        }while (read != 0);
                    }

                    TranslationLocation translation = SogoMapService.GetTranslationInfo(result);
                    if (translation != null && translation.response.points.Length == 1)
                    {
                        this.CurrentSogoLongitude = translation.response.points[0].longitude;
                        this.CurrentSogoLatitude  = translation.response.points[0].latitude;
                    }
                }
                catch
                {
                }
                //check whether need alert
                this.CheckReminder();
                this.lastUpdate = DateTime.Now;
            });
        }