Пример #1
0
        private async void txtboxEnd_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.Key.Equals(Key.Enter))
            {
                Task <string> returnString = Request.RequestToBingMap.sendGeoCodingRequest(txtboxEnd.Text.Trim());

                //handle json return to get lat & long
                JObject jsonObject = JObject.Parse(await returnString);

                string xlong = jsonObject.SelectToken("resourceSets[0].resources[0].point.coordinates[1]").ToString().Trim();
                string xlat  = jsonObject.SelectToken("resourceSets[0].resources[0].point.coordinates[0]").ToString().Trim();

                //set marker again

                if (endPointOverlay != null)
                {
                    myLocationLayer.Remove(endPointOverlay);
                }
                //dat pushpin
                endPointOverlay = MarkerDraw.DrawMapMarker(new GeoCoordinate(Convert.ToDouble(xlat), Convert.ToDouble(xlong)));
                // Create a MapLayer to contain the MapOverlay.
                myLocationLayer.Add(endPointOverlay);

                // Add the MapLayer to the Map.
                mapPostItinerary.Layers.Remove(myLocationLayer);
                mapPostItinerary.Layers.Add(myLocationLayer);

                this.Focus();
            }
        }
Пример #2
0
        private async Task <GeoCoordinate> ShowMyCurrentLocationOnTheMap()
        {
            // Get my current location.
            Geolocator  myGeolocator  = new Geolocator();
            Geoposition myGeoposition = await myGeolocator.GetGeopositionAsync();

            myGeocoordinate = myGeoposition.Coordinate;

            wayPoints.Add(new GeoCoordinate(myGeocoordinate.Latitude, myGeocoordinate.Longitude));
            //GeoCoordinate myxGeocoordinate = new GeoCoordinate(47.6785619, -122.1311156);

            myGeoCoordinate =
                CoordinateConverter.ConvertGeocoordinate(myGeocoordinate);

            // Make my current location the center of the Map.
            this.mapPostItinerary.Center    = myGeoCoordinate;
            this.mapPostItinerary.ZoomLevel = 16;


            // Create a MapOverlay to contain the circle.
            myCurentLocationOverlay = MarkerDraw.DrawMapMarker(myGeoCoordinate);

            // Create a MapLayer to contain the MapOverlay.
            myLocationLayer = new MapLayer();
            myLocationLayer.Add(myCurentLocationOverlay);

            // Add the MapLayer to the Map.
            mapPostItinerary.Layers.Add(myLocationLayer);

            return(myGeoCoordinate);
        }
Пример #3
0
        private void mapPostItinerary_Tap(object sender, System.Windows.Input.GestureEventArgs e)
        {
            if (endPointOverlay != null)
            {
                myLocationLayer.Remove(endPointOverlay);
            }
            GeoCoordinate asd = this.mapPostItinerary.ConvertViewportPointToGeoCoordinate(e.GetPosition(this.mapPostItinerary));

            //MessageBox.Show("lat: " + asd.Latitude + "; long: " + asd.Longitude);

            //dat pushpin
            endPointOverlay = MarkerDraw.DrawMapMarker(asd);
            // Create a MapLayer to contain the MapOverlay.
            myLocationLayer.Add(endPointOverlay);

            // Add the MapLayer to the Map.
            mapPostItinerary.Layers.Remove(myLocationLayer);
            mapPostItinerary.Layers.Add(myLocationLayer);

            //mapPostItinerary.Layers.Remove()
            //hien thi thong tin diem den tren textbox
            geoQ.GeoCoordinate = asd;

            geoQ.QueryAsync();
        }