[OpenLayers-Users] Vector points aver the dateline

David Zwarg dzwarg+ol at azavea.com
Tue Aug 31 09:30:04 EDT 2010


Hello Sylvain,

In my experience, I did the coordinate recalculations in javascript, and
dynamically constructed the geometries for the OpenLayers objects.  I
haven't tried the approach of having 2 vector layers, although I am thinking
that the 2 vector layers may not work as expected.

The reason I say that: I have a feeling that only 1/2 the vectors will be
rendered at one time if you use the 2 vector layers as described. I'll break
out some ASCII art to demonstrate:

+++++++++++++++++++++++++
+        |              +
+        ************************
+        |              +       *
+        *              +       *
+        |              +       *
+        *              +       *
+        |              +       *
+        ************************
+        |              +
+++++++++++++++++++++++++

In the above diagram:
  +++ : the extent of the map
  *** : the bounds of the vector layers (vectorWest and vectorEast)
  |   : the IDL

In this scenario, one of the vector feature layers will be rendered in the
left side of the *** box, and one of the vector feature layers will be
rendered in the right side of the *** box -- note that this is outside the
map extent. When the client pans across the IDL, the vector layer will get
shifted by OL to the opposite side of the IDL. Then the scenario becomes:

        +++++++++++++++++++++++++
        +              |        +
************************        +
*       +              |        +
*       +              *        +
*       +              |        +
*       +              *        +
*       +              |        +
************************        +
        +              |        +
        +++++++++++++++++++++++++

And you'll see the same effect as above, where features in the opposite side
of the vector layer will not be displayed. One vector feature layer will be
positioned in the left hand side of the *** box, which is outside the map
extent.

I think you'll need to adapt your logic to do the coordinate shifting and
feature replication in Javascript.  You can hook into the layers
'beforefeaturesadded' event to modify the features to multi-features, if you
want to use one json file request & load.

Let me know how you're able to finally get this working, I'm curious to know
if there's another way around it.

z

On Tue, Aug 31, 2010 at 2:41 AM, springrider <springrider at hotmail.com>
wrote:
>
> Hello David,
> Thanks for your reply, i have followed your recommendations and have now 2
> vectors layers containing same type of data but with coordinates adapted
to
> each side of the date line (-179 becoming +181 in one file and 179
becoming
> -181 in the other).
> vectorsWest = new OpenLayers.Layer.GML( "Releases", "pacific_W.json",
>                                                { format:
> OpenLayers.Format.GeoJSON,
>                                                  styleMap: styleMap,
>                                                  isBaseLayer: false,
>                                                  projection: new
> OpenLayers.Projection("EPSG:4326")}
>
                     );
>            vectorsEast = new OpenLayers.Layer.GML( "Releases",
> "pacific_E.json",
>                                                { format:
> OpenLayers.Format.GeoJSON,
>                                                  styleMap: styleMap,
>                                                  isBaseLayer: false,
>                                                  projection: new
> OpenLayers.Projection("EPSG:4326")}
>
                     );
>
> Would i have to add 2 vector layers or do you think the coordinate
> recalculations could be done at OL level from a unique Json file?
>
> Thanks
>
> Sylvain
> --
> View this message in context:
http://osgeo-org.1803224.n2.nabble.com/Vector-points-over-the-dateline-tp5478314p5481381.html
> Sent from the OpenLayers Users mailing list archive at Nabble.com.
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20100831/b91720a6/attachment.html


More information about the Users mailing list