Markers disappearing when dragging

554 views
Skip to first unread message

Tom Van Herreweghe

unread,
Sep 18, 2009, 9:01:11 AM9/18/09
to Google Maps JavaScript API v3
I'm building an application where I want to display multiple markers
on a map. I'm having an issue, when the map is loaded and all the
markers are displayed. If you start dragging the map, then the markers
disappear. If you then zoom in and out again, then you can drag the
map without losing the markers.

If you first click on a marker, and then start dragging the map, then
there is no problem.

I have put my example online here: http://staging.theanalogguy.com
Never mind the messy code, I'm rebuilding something that was built for
v2 of the API.

I have tested this on 3 different laptops, FF3, latest Safari and IE7.
They all suffered from disappearing markers.

Does anyone else have this problem, or does anyone know a solution for
this?



Thanks!!

Tom

Peter Carr

unread,
Sep 18, 2009, 9:06:46 AM9/18/09
to google-map...@googlegroups.com
Tom-

I can't seem to find a map on this page:
http://staging.theanalogguy.com/

Please check your link and send another one.
Thanks!
-Pete

Cameron F

unread,
Sep 18, 2009, 5:07:21 PM9/18/09
to Google Maps JavaScript API v3
I have seen similar behaviour - I know that Esa was looking at it as
well - comments are in this thread:

http://groups.google.com/group/google-maps-js-api-v3/browse_frm/thread/717b493927ad7a74

Haven't seen a resolution yet. Short version is for some reason the
left pixel position of the markers is getting set to a really high
number somewhere during the drag.

-Cam

jbizzay

unread,
Sep 18, 2009, 6:32:37 PM9/18/09
to Google Maps JavaScript API v3
Just to throw this out there, I had similar behaviour on my map, but
it seems to be resolved now. When I had this problem, I was
instantiating the map without a center option. I was getting all my
data for markers and the center with json server call, then calling
map.set_center, then setting all my markers.

Everytime, on first drag, my markers would fly off the screen.

Now, I construct the map with a center option instead of calling
map.set_center and I can drag before all the markers are set and it
works fine. I don't know why it matters.

If anyone wants me to, I'll post before and after links so you can see
the difference.

On Sep 18, 2:07 pm, Cameron F <cam_goo...@ferroni.net> wrote:
> I have seen similar behaviour - I know that Esa was looking at it as
> well - comments are in this thread:
>
> http://groups.google.com/group/google-maps-js-api-v3/browse_frm/threa...

Tom Van Herreweghe

unread,
Sep 19, 2009, 8:33:36 AM9/19/09
to Google Maps JavaScript API v3
I'm sorry for posting the wrong link. This is the correct one:
http://staging.theanalogguy.be/

jbizzay, I have set the center of the map in my mapoptions, but I
still have the problem.
The issue doesn't only arise when you drag the map, but also when you
use the map controls to pan the map left and right. Even using the
panTo method on the map object, can result in this or other strange
behavior.

Can anyone confirm they can also see the problem on the (now
correct :p) link? A colleague of mine says he doesn't have the issue
on his laptop, but others have confirmed they do see it.


Tom

jbizzay

unread,
Sep 19, 2009, 3:28:32 PM9/19/09
to Google Maps JavaScript API v3
I can confirm the markers are disappearing. Can you try this and see
if it fixes it? You have to make sure you are passing floats to LatLng
when using it to center the map.

In your mapsv3.js file, on line 46 change

var latlng = new google.maps.LatLng(this.config.startPoint
[0],this.config.startPoint[1]);

to

var latlng = new google.maps.LatLng(parseFloat(this.config.startPoint
[0]),parseFloat(this.config.startPoint[1]));



On Sep 19, 5:33 am, Tom Van Herreweghe <tom.vanherrewe...@edpnet.be>

Tom Van Herreweghe

unread,
Sep 20, 2009, 6:14:03 PM9/20/09
to Google Maps JavaScript API v3
Thanks jbizzay,

Even though it seems a bit strange, but adding the parseFloat() helped
solve the problem. Apparently, my coordinates were added as strings.
Funny what an effect that seems to have on the behavior of the Maps
API. Perhaps something that should be added in the API, to protect
dummies like me? :)

Tom

pamela (Google Employee)

unread,
Sep 20, 2009, 7:11:04 PM9/20/09
to google-map...@googlegroups.com
Hey Tom-

We looked into calling parseFloat ourselves, but it can have
unpredictable results depending on the input, and we determined it's
safer for developers to always send us in floats themselves.

- pamela

Tom Van Herreweghe

unread,
Sep 21, 2009, 3:51:39 AM9/21/09
to Google Maps JavaScript API v3
Hi Pamela,

I can agree with your decision to keep the responsability at the
developer's end, to provide floats. But maybe it would be a good idea
to just throw an exception if the format is incorrect. Because now the
LatLng object was filled in, and I didn't get a warning. So naturally
I assumed there was no problem there. Is this something you guys have
on the planning? (I'm not familiar with the roadmap)


Tom



On 21 sep, 01:11, "pamela (Google Employee)" <pamela...@gmail.com>
wrote:
> Hey Tom-
>
> We looked into calling parseFloat ourselves, but it can have
> unpredictable results depending on the input, and we determined it's
> safer for developers to always send us in floats themselves.
>
> - pamela
>
> On Mon, Sep 21, 2009 at 8:14 AM, Tom Van Herreweghe
>

pamela (Google Employee)

unread,
Sep 21, 2009, 3:53:46 AM9/21/09
to google-map...@googlegroups.com
Hey Tom-

Yes, we're looking into throwing a warning or such. Thanks for the idea.

- pamela

duffpl

unread,
Oct 20, 2009, 9:55:02 AM10/20/09
to Google Maps JavaScript API v3
Hi. Just wanted to say that i've encountered same problem as Tom did.
What really bugs me is why it initialy centers and positions the
marker on init and then gets bad on dragging the map. It shouldn't
center/put marker in good position in first place if latLang object
wasn't properly initialized. Warning message would be great addition.
Keep up the great work ! Greetings from cold Cracow [Poland]
Reply all
Reply to author
Forward
0 new messages