Reputation: 203
I want to develop a simple app to allow users to type in longitude and latitude to find the position in the map. I use Bing Map to develop it. I know how to get the current location, but I don't know how to get the geo-location manually.
Here is my code to get current geo-location and show it in the map. How can I modify it, to let user enter a geo-location?
Geopoint position = (await new Geolocator().GetGeopositionAsync()).Coordinate.Point;
DependencyObject marker = Library.Marker();
MyMap.Children.Add(marker);
MapControl.SetLocation(marker, position);
MapControl.SetNormalizedAnchorPoint(marker, new Point(0.5, 0.5));
MyMap.ZoomLevel = 15;
MyMap.Center = position;
Upvotes: 1
Views: 692
Reputation: 10627
I want to develop a simple app to allow users to type in longitude and latitude to find the position in the map.
Since you already get the longitude and latitude values, you could just build a BasicGeoposition
struct with longitude and latitude values, and create a geographic point object for the given position. For example:
Geopoint position = new Geopoint(new BasicGeoposition()
{
//Geopoint for Seattle
Latitude = 47.604,
Longitude = -122.329
});
...
MapControl.SetLocation(marker, position);
Upvotes: 2