Adding a clickable layer

3382
4
Jump to solution
10-05-2015 09:03 AM
Highlighted
New Contributor III

I am trying to do the following:

When you click on a button, a country or a set of highlighted countries are displayed.

next, click on a country and you zoom in to a highlighted city or cities.

I want to display the city/cities as a clickable layer when you zoom in

Currently, I can click and zoom in on a highlighted country and the city looks like a dot..  (ICGC WEB PORTAL )

Any suggestions are welcome!!

Chris

Tags (2)
Reply
0 Kudos
1 Solution

Accepted Solutions
Highlighted
Frequent Contributor

the click event for your cityLayer isn't triggered because you're adding it to the map before (and therefore underneath) the countries.

View solution in original post

4 Replies
Highlighted
Frequent Contributor
I want to display the city/cities as a clickable layer

what is a 'clickable layer'? 

the city looks like a dot

what do you expect the cities to look like?

you'll have to be a lot more specific about what exactly what you're trying to accomplish and what you've already tried in order for someone to be able to help you.

Reply
0 Kudos
Highlighted
New Contributor III

By clickable I mean when you click on the city, data about the city will be

displayed in the side panel

So here is what I am trying to make happen:

Step 1, Click on the country and zoom into and center on the city.

Step 2. Click on the city and data about the city is displayed in the side

panel

I defined a city url:

var cityURL = 'http://....../StRaphaelOSM/MapServer/;

and added the following code

var cityLayer = L.esri.featureLayer().addTo(map);

cityLayer.on('click', function(evt) {

var bounds = evt.layer.getBounds()

map.fitBounds(bounds);

});

Reply
0 Kudos
Highlighted
Frequent Contributor

the click event for your cityLayer isn't triggered because you're adding it to the map before (and therefore underneath) the countries.

View solution in original post

Highlighted
New Contributor III

John:

Thanks for pointing that out!!

Problem solved!!

Chris

Reply
0 Kudos