Page 1 of 1

dragging map doesn't change center

Posted: Wed Apr 29, 2015 4:10 pm
by Ben Walker

I am trying to set local storage variables using a G-map.

On a button click event two storage variables should be set, corresponding to the center of the G-map (Lat and Lng). For longitude I have done this using:

Bind to component: True
Target component: map
Property name: longitude

However, the point is that if the map is dragged, the center latlng is changed. And when the button is clicked, the current center of the map (after being dragged) is stored in local storage.

However, it doesn't seem like the center of the G-map is changing when the map is dragged, since the lat and lng stored in local storage seems to be the center of the map when it was first initialized (before being dragged).

Any help much appreciated - how to I get the center coordinates of the map to change as it is dragged?

Thanks!


dragging map doesn't change center

Posted: Wed Apr 29, 2015 5:13 pm
by Bruce Stuart

Ben,

Is the map being dragged or the marker is being dragged?

You can find sample code on this thread... where you pan a map to a new position...

https://getsatisfaction.com/apperyio/...

and some sample functions here.

http://the-software-studio.com/javasc...

Specifically - but not sure if it addresses the problem - you can pan a map to a new center (where your map name is replaces oMyMap and the new center of the map is a Google position object called oposition ) with this code...

Code: Select all

 oMyMap.panTo( oposition  ); 

You can get the coordinates of a marker as it is being dragged - using the code in the 2nd link above (it records new positions to local storage as the marker is being dragged).

Bruce


dragging map doesn't change center

Posted: Wed Apr 29, 2015 5:59 pm
by Ben Walker

Thanks Bruce.

It's the map that is being dragged. And upon further investigation it looks like the center of the map is changing as the map is dragged.

However, when I run a list service to put all the markers on the map, the map re-centers back to the old position (before it was dragged).

That's the problem - I need the map to stay centered where I leave it, and not move when markers are listed on the map.