Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm using Leaflet API and geojson. I defined a function which zooms to the feature when clicked:

function zoomToFeature(e) {

 function onEachFeature(feature, layer) {
                    mouseover: highlightFeature,
                    mouseout: resetHighlight,
                    click: zoomToFeature

But, I don't need to zoom on the feature, but to go to the URL. So, when user click on polygon on the map, it takes him to some url.

Is that possible and how? I thought I can maybe define some function which will lead to the url, and then pass it to layer.on click event, but not sure how.

Thank you for any help.

share|improve this question
up vote 1 down vote accepted

Keep the code the same just replace the map.fitBounds(; with'','_blank');

share|improve this answer

Quick answer to your message, It seems you basically want to redirect the user right ? I am not familiar with LeafLet but perhaps you can try with a function like :

            function redirect(e)
                // assuming you have a url property embeded in your feature
                var url =; 
                // or hardcoded as...
                var url = "http://www.somelink";
            // then call it on the click event :
            click: redirect

my two cents ..

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.