Adding a clickable layer

3951
4
Jump to solution
10-05-2015 09:03 AM
joepublic
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)
0 Kudos
1 Solution

Accepted Solutions
JohnGravois
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
JohnGravois
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.

0 Kudos
joepublic
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);

});

0 Kudos
JohnGravois
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.

joepublic
New Contributor III

John:

Thanks for pointing that out!!

Problem solved!!

Chris

0 Kudos