This usecase aims to provide a View to an Openlayers Preset that provides:
1. The default Google Terrain as a baselayer (normally 900913 projection)
2. A number of overlay layers that the user can enable/disable in the map viewer. These overlay layers are all served through normal WMS and are 4326 projection
The first step has been to define the Overlay layers so that they are available for selection in the Preset admin process.
In the Preset admin, the default 900913 projection is left in place, the Map Projection is left at 4326, and:
- the Google baselayer is available
- the overlay layers are *not* available
When the projection is changed to 4326:
- the Google baselayers dissappear and
- the overlay layers appear.
Thus it seems impossible to create the preset as expected. Is this functioning as designed?
If so, could someone please advise on how the desired outcome can be achieved?
Thanks indeed...
Comments
Comment #1
tmcw commentedWell, yes. Google Maps are in the EPSG:900913 projection. Your overlays are served in EPSG:4326. OpenLayers can reproject vector data, like OpenLayers Views results, KML, and the like, but it's extremely infeasible to reproject raster data - tiles - in browser, since this would require math for warping tiles, requesting odd tile areas, etc.
Your desired outcome is only possible by getting your overlays in EPSG:900913, or, if you don't control them, re-serving them in EPSG:900913 using TileCache.
Comment #2
boabjohn commentedThanks Tom for the guidance. Actually, most of the overlays are vector based (lines, not pixels)...so is there a way to "enable" OpenLayers to do the reprojection?
And where would I go to start investigating TileCache (for the raster layers)?
Comment #3
tmcw commentedHuh? If they're WMS layers, when they're hitting Drupal, they're tiles - they're rasterized - unless you're using a WMS GetFeatures call or similar, which isn't supported by this module yet. If you're saying that the backing data is vector, then it should be possible to set up your WMS server to serve the tiles as EPSG:900913, and then accordingly add them to Drupal in that projection.
Comment #4
boabjohn commentedYes of course, sorry for the confusion...
I'm still fighting disorientation in the Preset admin screen where there appear to be three separate choices/advisories for projections.
I'll go back and make changes on the WMS side of things.
Thanks heaps and much appreciation for the module.
Comment #5
anarcat commentedI have a similar issue here - i add "points" as an overlay to a Google maps layer. Since I receive the coordinates from a GPS device, I need to manually convert those coordinates between the two projects, which involves:
1. going to maps.google.com
2. entering the coordinates in the search box
3. clicking on the resulting point
4. zooming in
5. copying the URL in the WKT field
6. saving the node
7. saving it again, because of #981966: Update map when WKT field loses focus
This is a really painful and error-prone process. (And if you have a better idea, please tell!)
I would rather just put the two coordinates in the WKT field and have Drupal magically convert it to the "right" projection. If the overlay was in the right projection, and converted to the base layer projection, I think this would work.
Comment #6
zzolo commentedHi @anarcat. So, there is a couple of ways that this could happen, though not sure if any of them are existing clickable solutions.
1) You could create formatter for the CCK field to re-project as it comes out.
2) You could set the projection of the data layer, and therefore, OpenLayers would know about the different projection and re-project as needed (this only works if you are using lat/lon or mercator projects, as any other projection conversion is not built into OpenLayers). At least this is my understanding. Also, this could be accomplished with the openlayers render hooks.
3) Create a patch that allows for better project handling. :)
Comment #7
mathieu commentedHI @zzolo. I'm working on the same issue as @anarcat.
If I understand you correctly, the OL map is displayed in EPSG:4326, while the GPS data is in EPSG:900913?
I'm a bit confused about the "render" hook you talk about. Is this in the javascript code, or does this require core extending openlayers_behavior?
Comment #8
zzolo commentedHi @mathieu. Check out the openlayers.api.php file in the docs/ folder that describes the render hooks, which basically allow you to manipulate the map as it gets rendered.
Comment #9
zzolo commentedFollow the projection discussion over here: #1331410: Better Handling of Projections