[OpenLayers-Dev] Patrch for getting vector drawing working over the 180 line going.

Andreas Hocevar ahocevar at opengeo.org
Fri Aug 13 15:00:16 EDT 2010


Hi Phil,

I took a quick look at the path that Piero and you took. The problem I see with this approach is that you take the coordinates from Map.getLonLatFromPixel (which are already fixed to repsect the date line), and make them invalid again (i.e. putting the x value outside the projection's maxExtent.

The place where dateline handling should be solved for vector features is in the vector renderers, probably in Renderer.drawFeature. There you should check if the currently visible extent crosses the date line, and process x coordinates of the geometries that are about to be drawn - just like you do now in the handlers.

I don't think you need to store LIMIT and GLOBE_LON anywhere. You can use the maxExtent, just like all the other date line wrapping code does (see e.g. Layer.getLonLatFromViewPortPx).

I hope this helps a bit. Thanks for your efforts to make features work that cross the date line.

Regards,
Andreas.

On Aug 13, 2010, at 07:03 , Phil Scadden wrote:

> Following on from Piero's regularpolygon code for drawing across the 180 
> line, I have modified path.js and
> polygon.js to manage this feat as well. (ATTACHED FILES) My code is 
> somewhat simpler. The basic idea is that if the right margin of the map 
> have coordinates that are less the left margin of the map, then you have 
> a 180 degree line hassle somewhere in there, and the lat/lon returns 
> need to be modified. So far so good. This let me use say distance and 
> area tools on google maps which include the 180. I still havent mastered 
> the box drawing so you can zoom in on an area that includes the 180 
> lines somewhere in it.
> 
> However, the code is not general. The properties (repeated unnessarily 
> in both classes) are for google projection only. Calculating these for 
> using the map projection is straightforward so can improve that but 
> where should these properties reside? It seems to me from structure of 
> openlayers, that they should be map properties but I am somewhat 
> reluctant to add to this. Advice from developers please. I would like to 
> get this working (including for box) and submitted as a patch.
> 
> 
> -- 
> Phil Scadden, Senior Scientist GNS Science Ltd 764 Cumberland St, 
> Private Bag 1930, Dunedin, New Zealand Ph +64 3 4799663, fax +64 3 477 5232
> 
> Notice: This email and any attachments are confidential. If received in error please destroy and immediately notify us. Do not copy or disclose the contents.
> 
> <Polygon.js><Path.js>_______________________________________________
> Dev mailing list
> Dev at openlayers.org
> http://openlayers.org/mailman/listinfo/dev



-- 
Andreas Hocevar
OpenGeo - http://opengeo.org/
Expert service straight from the developers.




More information about the Dev mailing list