<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Infinity Code Forum — Get new Lat/Lng after marker drag]]></title>
	<link rel="self" href="https://forum.infinity-code.com/extern.php?action=feed&amp;tid=643&amp;type=atom" />
	<updated>2017-09-08T22:39:04Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.infinity-code.com/viewtopic.php?id=643</id>
		<entry>
			<title type="html"><![CDATA[Re: Get new Lat/Lng after marker drag]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=2770#p2770" />
			<content type="html"><![CDATA[<p>Great Thanks!&nbsp; My issue was as I was logging it to the console I was using Debug.Log(playerMarker.position); and it was only logging the Vector2 to only 1 decimal place.<br />Thanks again for clearing this up.</p>]]></content>
			<author>
				<name><![CDATA[andyhast81]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=540</uri>
			</author>
			<updated>2017-09-08T22:39:04Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=2770#p2770</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Get new Lat/Lng after marker drag]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=2769#p2769" />
			<content type="html"><![CDATA[<p>Hello.</p><p>I tested your code, and it works correctly.<br />The coordinates of the marker is changes.<br />Most likely, you just do not see a change because Vector2.ToString shows only one decimal point.<br />Use:<br />Debug.Log(playerMarker.position.ToString(&quot;F4&quot;));<br />or<br />Debug.Log(playerMarker.position.x + &quot;&nbsp; &nbsp;&quot; + playerMarker.position.y);</p>]]></content>
			<author>
				<name><![CDATA[Alex Vertax]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=2</uri>
			</author>
			<updated>2017-09-08T02:28:56Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=2769#p2769</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Get new Lat/Lng after marker drag]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=2768#p2768" />
			<content type="html"><![CDATA[<p>Hello,</p><p>I&#039;m trying to allow the user to edit their location that is created by the OnlineMapsLocationService.&nbsp; If the user thinks the marker should be in a different spot they can long press then drag the marker.</p><p>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.&nbsp; Any help on getting the new lat/lng after dragging the marker would be great.&nbsp; My code is below.</p><div class="codebox"><pre><code>public class GetCurrentLocation : MonoBehaviour{

  private OnlineMapsMarker playerMarker;
    
    private void Start(){
        // Create a new marker.
    playerMarker = OnlineMaps.instance.AddMarker(new Vector2(0, 0), null, &quot;marker&quot;);
        if (locationService == null){
        Debug.LogError(
            &quot;Location Service not found.\nAdd Location Service Component (Component / Infinity Code / Online Maps / Plugins / Location Service).&quot;);
                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);

    }

}</code></pre></div>]]></content>
			<author>
				<name><![CDATA[andyhast81]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=540</uri>
			</author>
			<updated>2017-09-08T02:08:43Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=2768#p2768</id>
		</entry>
</feed>
