I've got a simple Leaflet map with a basemap and one map-layer coming from my own hosted GeoServer.
I made the layers show up nicely in a map.
Now I want to add popups on the point layer showing information stored in MapService.
I couldn't find too much information about that topic.
There's one link to a working example but the link seems to be broken. I found another example which I addopted. You can see it on JSFiddle. I'd like to display the content of the name field in the attribute table but nothing happens when the user clicks the map.
Any idea?
Answer
The problem with your jsfiddle is that you try to do a Cross-Domain-Request that gets blocked due to the Same-Origin-Policy.
I could imagine that this is the same Problem on your server. If you host your Leaflet-App on Port 80 and try to get the Feature-Info from port 8080 this will be blocked. You can solve this problem by making your geoserver available on port 80,too or by using a proxy-file.
The first option would be less efford, so perhaps you could try this first.
Here you'll find more information: Getting WFS data from Geoserver into leaflet https://gist.github.com/jacobandresen/1004676
The other option would be to set up a proxy-file (php-file for example) and perhaps also use L.TileLayer.BetterWMS ( https://gist.github.com/rclark/6908938 ) which works,too:
No comments:
Post a Comment