Esempio n. 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.DrawCurrentMapMarker(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();
            }
        }
Esempio n. 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));

            myGeoCoordinate = CoordinateConverter.ConvertGeocoordinate(myGeocoordinate);

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

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

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

            myLocationLayer.Add(myCurentLocationOverlay);

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

            return(myGeoCoordinate);
        }
Esempio n. 3
0
        private void mapPostItinerary_Tap(object sender, System.Windows.Input.GestureEventArgs e)
        {
            if (isSetEndPoint)
            {
                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.DrawEndMarker(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();
            }
            else
            {
                if (startPointOverlay != null)
                {
                    myLocationLayer.Remove(startPointOverlay);
                }
                GeoCoordinate asd = this.mapPostItinerary.ConvertViewportPointToGeoCoordinate(e.GetPosition(this.mapPostItinerary));
                //MessageBox.Show("lat: " + asd.Latitude + "; long: " + asd.Longitude);

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

                // 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();
            }
        }