Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 77050

How to change Pin position on location changed event

$
0
0

I am developing an app to track users live location.I have the updated positions from geolocator plugin.when i get new positions i change the pin position.But it is not changing in the map.Here is the code,
this method is called in every 1 sec
private async void TrackMe()
{
var current = await CrossGeolocator.Current.GetPositionAsync();
current.Accuracy = 30;
float bearing =float .Parse ( current.Heading.ToString ());
var pins = new Pin { Label = "ME", Icon = BitmapDescriptorFactory.FromBundle("path4646.png"), Flat = true };
var latitude = current.Latitude;
var longitude = current.Longitude;
Device.BeginInvokeOnMainThread(() =>
{
pins.Position = new Position(latitude, longitude);
pins.Rotation = bearing;
if (MapTrack.Pins.Count == 0)
{
MapTrack.Pins.Add(pins);
}
MapTrack.MoveCamera(CameraUpdateFactory.NewPosition(new Position(latitude, longitude)));
});
}

Any help will appreciated, thanks in advance
Regards


Viewing all articles
Browse latest Browse all 77050

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>