leaflet - layers (Google, WMS and OSM) Proj4Leaflet EPSG 4326

1,416 views
Skip to first unread message

Renato Duarte

unread,
Apr 16, 2014, 10:27:24 AM4/16/14
to leafl...@googlegroups.com
hi ppl, 

i'm working with some tile layers, and i want to define osm base tile layer into the projection EPSG:4326, because i need to define my scales,  which is very important in my project. i made some example, 

http://jsfiddle.net/rntdrt/9RA6p/2/

I don't have de wms, cause it's still in my localhost.. in the example i think google, have tiles already in EPSG:4326 and that's why it's working fine and OSM doesn't... the locations should show Aveiro, Portugal...but that doesn't happen, i can't really understand why. I'm new in this kind of matter, so i hope that you can help me solve this problem, and teach me something...

Diego Guidi

unread,
Apr 16, 2014, 10:44:55 AM4/16/14
to leafl...@googlegroups.com
Actually google and osm tiles are in "google" projection:
http://goo.gl/1MlqiJ but conversion from/to 4326 is managed internally
by leaflet.
Anyway, using "tiles" mean that you're using static images, i.e:
images defined for a fixed resolution/scale. If you need your own
resolutions, you need your set of tiles, as far as I know.

A simpler approach: here's a list of public WMS servers fro OSM data.
http://wiki.openstreetmap.org/wiki/WMS#OSM_WMS_Servers

Diego Guidi
> --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "Leaflet" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to leaflet-js+...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Renato Duarte

unread,
Apr 16, 2014, 12:34:29 PM4/16/14
to leafl...@googlegroups.com
ok, thank you for the reply and for the information shared.
 
i want the map to project CRS in EPSG 4326... but everything i try, the tiles are changing to the wrong places... making it strange on the markers that i load with the wfs.
 
The best approach it's the L.CRS.EPSG4326 from leaflet, but it projects the tiles wrong too, i can't understand why and i can't fixe it...

But if i define in the wms that i want the projection to be in CRS EPSG 4326, the leaflet get it right... i search around and i see some bugs fixed in the next version (0.8) while i'm currently using the last one (0.7.2)..

Diego Guidi

unread,
Apr 16, 2014, 3:24:20 PM4/16/14
to leafl...@googlegroups.com


On Wednesday, April 16, 2014, Renato Duarte <rntd...@gmail.com> wrote:
The best approach it's the L.CRS.EPSG4326 from leaflet, but it projects the tiles wrong too, i can't understand why and i can't fixe it...


As far as I know, to use 4326 and 900913 projections, you don't need proj.js library.
I'm pretty sure that with standard resolutions all tiles are ok, as with wms.
So I think that if you need your own tiles you need to generate tiles by yourself, maybe using a WMS OSM provider as data source. Hope this helps: http://www.maptiler.org


--

Diego Guidi

Renato Duarte

unread,
Apr 17, 2014, 7:20:01 AM4/17/14
to leafl...@googlegroups.com
well the problem is not the resolutions alone, the problem is that i want to define my resolutions... because i need precision in the work i'm doing... i have the resolutions in my geoserver, and i can use that... but the only precision i will have is in the tiles i generate (EPSG:4326, and yes i have my own tiles) but, the map uses EPSG3857, so the tiles of OSM and GMAPS will not give me the same precision as i set the scale i want...

I need to set the resolutions for the whole map independent of the EPSG i'm using. even if i'm using OSM that provides EPSG:3857 and in EPSG:4326 for the map that i have generated and provided on GeoServer. But i need to define the resolutions, and i can't do that, maybe i'm missing something simple, but leaflet as capable of doing it... i'm almost certenly.

Diego Guidi

unread,
Apr 17, 2014, 7:25:26 AM4/17/14
to leafl...@googlegroups.com
Why you don't generate tiles directly in 3857 format?

Actually, I'm a bit confused about how do you need and what
architecture/data do you have...

Diego Guidi

Renato Duarte

unread,
Apr 17, 2014, 9:44:58 AM4/17/14
to leafl...@googlegroups.com
well i have 3 tiles (osm in EPSG:3857, google maps in EPSG:3857 and wms EPSG:4326) and one overlayer (using WFS with GeoJson) for the POI's and the data about them. 

As normal the CRS of leaflet by default is in EPSG:3857 and i want to change that for EPSG:4326 and for my resolutions. If i keep the CRS by default, when i change for the wms tiles the send request is in EPSG3857, so Geoserver makes the automatic change of my tiles for the tiles of the request. If i change in the wms layer, that i want the EPSG:4326, the leaflet accepts and display it right away.. 

but if i change the map to display all tiles in EPSG:4326, the tiles of OSM don't show right, the position is wrong. the Google Maps and the wms are right.

i hope this can clarify you.. 

Diego, first of all, thanks. i really apreciated all the help. 

Diego Guidi

unread,
Apr 17, 2014, 10:54:55 AM4/17/14
to leafl...@googlegroups.com
On Thu, Apr 17, 2014 at 3:44 PM, Renato Duarte <rntd...@gmail.com> wrote:
> but if i change the map to display all tiles in EPSG:4326, the tiles of OSM
> don't show right, the position is wrong. the Google Maps and the wms are
> right.


This looks strange to me, because AFAIK (not so much actually) you
should see the same error using google or using osm. Maybe google
leaflet plugin restore the correct resolutions under the hood?
Anyway, to me you should use 3857 and maybe reproject WFS source (WFS
1.1 should allow that) and WMS.

Another viable solution is to go with wms sources only: you should
configure geowebcache (geoserver tile provider) to act like WMS
(http://geowebcache.org/docs/1.5.1/services/wms.html) so he can take
care of resolution issues for you.
Hole someone can be more helpful.


Diego Guidi

Renato Duarte

unread,
Apr 17, 2014, 12:41:23 PM4/17/14
to leafl...@googlegroups.com
i agree with you on the 3857 thing. it would make things easier. So i was trying to define my scales in 3857 but guess what? doesn't work either... lol 

this should be a easy thing to do? no? defining scales to project?!!
Reply all
Reply to author
Forward
0 new messages