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); }
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(); } }
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(); }
public void addMarkertoMap(GeoCoordinate point) { mapMain.Layers.Remove(mainMapLayer); mainMapLayer = new MapLayer(); overlay = MarkerDraw.DrawItineraryMarker(point, new Itinerary2()); mainMapLayer.Add(overlay); mapMain.Layers.Add(mainMapLayer); }
public async void getItinerary() { mainMapLayer = new MapLayer(); var result = await Request.RequestToServer.sendGetRequest("itineraries"); JObject jsonObject = JObject.Parse(result); string error = jsonObject.Value <string>("error").Trim(); //var xlong = jsonObject.SelectToken("itineraries"); JArray jsonVal = (JArray)jsonObject.SelectToken("itineraries"); //Convert json to object root = JsonConvert.DeserializeObject <RootObject>(result); foreach (Itinerary i in root.itineraries) { Global.GlobalData.itinearyList.Add(new Itinerary2 { itinerary_id = i.itinerary_id, driver_id = i.driver_id, customer_id = Convert.ToInt32(i.customer_id), start_address = i.start_address, start_address_lat = i.start_address_lat, start_address_long = i.start_address_long, end_address = i.end_address, end_address_lat = i.end_address_lat, end_address_long = i.end_address_long, pick_up_address = i.pick_up_address, pick_up_address_lat = i.pick_up_address_lat, pick_up_address_long = i.pick_up_address_long, drop_address = i.drop_address, drop_address_lat = i.drop_address_lat, drop_address_long = i.drop_address_long, cost = i.cost, distance = i.distance, description = i.description, duration = i.duration, status = i.status, created_at = i.created_at, leave_date = i.leave_date, driver_license = i.driver_license, driver_license_img = i.driver_license_img, user_id = i.user_id, email = i.email, fullname = i.fullname, phone = i.phone, personalID = i.personalID, //convert base64 to image link_avatar = ImageConvert.ImageConvert.convertBase64ToImage(i.link_avatar), average_rating = i.average_rating }); MapOverlay overlay = new MapOverlay(); overlay = MarkerDraw.DrawItineraryMarker(new GeoCoordinate(Convert.ToDouble(i.start_address_lat), Convert.ToDouble(i.start_address_long)), Global.GlobalData.itinearyList.Last()); //chua su dung //listMainMapOvelay.Add(overlay); mainMapLayer.Add(overlay); } mapMain.Layers.Add(mainMapLayer); longlistItineraries.ItemsSource = Global.GlobalData.itinearyList; }