[OpenLayers-Dev] Vector layer marker drifting with Google base map

kellett webmaster at kellett.nt.ca
Thu Jan 8 14:34:13 EST 2009


I am also having a similar problem.  I have read the OpenLayers Wiki in
detail on how to properly set the map projection and also to set the
projection to be used for the vector layer so they get properly re-projected
onto the map in the right place.

I am able to get it to draw the shapes in the right place and keep them
there when you zoom or pan the map. BUT, I can only zoom in and out. 
Panning does not work, either by clicking and dragging or by clicking the
arrow buttons in the top-left corner.  In addition, I want my map to start
centered and zoomed in on the Nunavut Territory in Northern Canada, since
the map is for a client in Nunavut and it's purpose is to show layers of
data just for Nunavut.  But when I'm using the right projection for
everything, it starts at the right zoom level but is centered on the middle
of the world (where the equator and prime meridian meet) rather than on the
Nunavut Territory.

I can't figure out what I'm doing wrong.  I copied and pasted code from the
manual page for setting the correct projection for the map, setting the
Google map layer to spherical mercator, and also setting the projection used
by my sample vector data to the right one.  I then just made little tweaks
to it for project.

The vector data files I used were taken from the OpenLayers examples.  I
grabbed one in GML format and another in KML to test with the two data
types.

I have coded up some prototypes, and have one where the panning and zooming
both work but the vector layers drift, and another where they don't drift
but the panning and default centering don't work.

I would greatly appreciate if somebody could have a look at my source code
and advise me on what I might be doing wrong.  I have uploaded my map
prototypes to the following URL:

http://npcmap.kellett.ca

Going to this URL will show my first really simple prototype that doesn't
have the vector layers.  The two prototypes that need checking are:

http://npcmap.kellett.ca/index2.php - this is the one that correctly starts
centered on Nunavut, can be panned, but the test vector layer shifts around. 
The vector shape is supposed to be over France, so you'll have to pan over
there to see it.

http://npcmap.kellett.ca/index3.php - this is the one that has the
projections set right so the vectors don't drift, but you can't pan and it
starts centered in the middle of the world.  Also clicking to zoom to max
extent doesn't work - the tileset disappears when you do.  This one has the
same vector shape over France, as well as a second one over Arizona.  Zoom
out 2 or 3 levels to see them.

All my Javascript code for initializing the maps is found here:

http://npcmap.kellett.ca/scripts/NPCMap.js

Take a look at the init function to see the code that initializes each of
the map prototypes.  All three maps are initialized in the same function,
I've just used jQuery to look for the existence of the div tag in which to
initialize the map on each page.

I can paste my code in here if that's preferred.
-- 
View this message in context: http://n2.nabble.com/Vector-layer-marker-drifting-with-Google-base-map-tp1835811p2129630.html
Sent from the OpenLayers Dev mailing list archive at Nabble.com.




More information about the Dev mailing list