Marker's latitude and longitude by JavaScript

Aug 31, 2009 at 7:53 PM

Hello, i have this piece of code

    <input type="text" id="Label1" />
    <input type="text" id="Label2" />

    <script type="text/javascript">
    function __showInfo(overlay, point) {
        if(point) {
            document.getElementById('Label1').value = point.lat();
            document.getElementById('Label2').value = point.lng();
        }
    }
    </script>

    <artem:GoogleMap ID="GoogleMap1" runat="server" Width="680px" Height="560px" Latitude="48.85"
        Longitude="2.35" Zoom="8" OnClientClick="__showInfo">
        <Markers>
            <artem:GoogleMarker Latitude="48.85" Longitude="2.35" Draggable="true" />
        </Markers>
    </artem:GoogleMap>

and it works fine - when i click on the map it put lat and long values into my html input boxes

But i need tu read this coordinates when i move my marker - I've tried use this: OnClientDragEnd="__showInfo", but doesn't work

Can anyone help wit this?

Regards

 

Sep 1, 2009 at 11:44 AM

try MarkerEvents-OnClientDragEnd="__showInfo"


MarkerEvents-OnClientDragEnd
Sep 1, 2009 at 5:43 PM
Edited Sep 1, 2009 at 5:46 PM

still nothing,

none of MarkerEvents* doesn;t works,
works only OnClientClick, OnClientDoubleClick etc.
no difference whether I add a marker in the aspx code and in code behind file

any other ideas?

Coordinator
Sep 2, 2009 at 6:28 AM

Hi,

You are using wrong events. Above you are registering for the map event, but the markers'.
You have to register for marker client event OnClientDragEnd.

In other words your code should look like:

<input type="text" id="Label1" />
    <input type="text" id="Label2" />

    <script type="text/javascript">
    function __showInfo(point) {
        if(point) {
            document.getElementById('Label1').value = point.lat();
            document.getElementById('Label2').value = point.lng();
        }
    }
    </script>

    <artem:GoogleMap ID="GoogleMap1" runat="server" Width="680px" Height="560px" Latitude="48.85"
        Longitude="2.35" Zoom="8" OnClientClick="__showInfo">
        <Markers>
            <artem:GoogleMarker Latitude="48.85" Longitude="2.35" Draggable="true" />
        </Markers>
        <MarkerEvents OnClientDragEnd="__showInfo" />
    </artem:GoogleMap>
Please, notice in the sample here _showInfo was changed to accept just one parameter - the GLatLng.
Regards
Sep 9, 2009 at 5:57 PM

This works fine velio, thanks