Topic: Get new Lat/Lng after marker drag
Hello,
I'm trying to allow the user to edit their location that is created by the OnlineMapsLocationService. If the user thinks the marker should be in a different spot they can long press then drag the marker.
Everything is working except when trying to get the new lat/lng OnMarkerRelease, it always shows the same coordinates no matter how far away I drag the marker. Any help on getting the new lat/lng after dragging the marker would be great. My code is below.
public class GetCurrentLocation : MonoBehaviour{
private OnlineMapsMarker playerMarker;
private void Start(){
// Create a new marker.
playerMarker = OnlineMaps.instance.AddMarker(new Vector2(0, 0), null, "marker");
if (locationService == null){
Debug.LogError(
"Location Service not found.\nAdd Location Service Component (Component / Infinity Code / Online Maps / Plugins / Location Service).");
return;
}
// Subscribe to the change location event.
locationService.OnLocationChanged += OnLocationChanged;
playerMarker.OnLongPress += OnMarkerLongPress;
playerMarker.OnRelease += OnMarkerRelease;
}
// When the location has changed
private void OnLocationChanged(Vector2 position){
// Change the position of the marker.
// Redraw map.
OnlineMaps.instance.Redraw();
}
private void OnMarkerLongPress(OnlineMapsMarkerBase playerMarker){
// Starts moving the marker.
OnlineMapsControlBase.instance.dragMarker = playerMarker;
OnlineMapsControlBase.instance.isMapDrag = false;
}
private void OnMarkerRelease(OnlineMapsMarkerBase playerMarker){
Debug.Log (playerMarker.position);
}
}