Leaflet info box only showing properties from selected layer The 2019 Stack Overflow Developer Survey Results Are InLeaflet: 4 overlay layers, 1 click, get properties of all intersecting polygons.Turf intersect point with Leaflet GeoJSON errorChanging list-item css class using ng-class when mousing over Leaflet Map Markers?A problem with event firing upon mouseoutMarkerCluster don't work with geojson layer in leafletDynamically change Leaflet layerLeaflet: 4 overlay layers, 1 click, get properties of all intersecting polygons.Adding PieChart Layer through DVF in a Leaflet mapDefining which layer (overlay) is displayed on Leaflet map?How to plot Feature properties into a html div label using Leaflet and omnivore?Leaflet - How to show feature properties in a box that is not a popup?Leaflet info box error on same name properties in multiple layers
What do hard-Brexiteers want with respect to the Irish border?
Is it possible for the two major parties in the UK to form a coalition with each other instead of a much smaller party?
Understanding the implication of what "well-defined" means for the operation in quotient group
Why is the maximum length of OpenWrt’s root password 8 characters?
Falsification in Math vs Science
Does light intensity oscillate really fast since it is a wave?
How are circuits which use complex ICs normally simulated?
Does duplicating a spell with Wish count as casting that spell?
Unbreakable Formation vs. Cry of the Carnarium
Why isn't airport relocation done gradually?
How was Skylab's orbit inclination chosen?
I looked up a future colleague on LinkedIn before I started a job. I told my colleague about it and he seemed surprised. Should I apologize?
I see my dog run
What can other administrators access on my machine?
JSON.serialize: is it possible to suppress null values of a map?
How to manage monthly salary
What effect does the “loading” weapon property have in practical terms?
What are my rights when I have a Sparpreis ticket but can't board an overcrowded train?
What does "sndry explns" mean in one of the Hitchhiker's guide books?
Could JWST stay at L2 "forever"?
Is there a name of the flying bionic bird?
What is the use of option -o in the useradd command?
Lethal sonic weapons
What is this 4-propeller plane?
Leaflet info box only showing properties from selected layer
The 2019 Stack Overflow Developer Survey Results Are InLeaflet: 4 overlay layers, 1 click, get properties of all intersecting polygons.Turf intersect point with Leaflet GeoJSON errorChanging list-item css class using ng-class when mousing over Leaflet Map Markers?A problem with event firing upon mouseoutMarkerCluster don't work with geojson layer in leafletDynamically change Leaflet layerLeaflet: 4 overlay layers, 1 click, get properties of all intersecting polygons.Adding PieChart Layer through DVF in a Leaflet mapDefining which layer (overlay) is displayed on Leaflet map?How to plot Feature properties into a html div label using Leaflet and omnivore?Leaflet - How to show feature properties in a box that is not a popup?Leaflet info box error on same name properties in multiple layers
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I would like to use the info box as shown in the tutorial interactive choropleth map with multiple layers and properties from different layers.
The idea is to only show the properties from the selected layer.
For example the infobox has both Statename and Cityname as properties. Statename is a property in the layer States and Cityname is a property in the layer Cities.
var info = L.control(position:'topleft');
info.onAdd = function (map)
this._div = L.DomUtil.create('div', 'info');
this.update();
return this._div;;
info.update = function (pro)
this._div.innerHTML = '<h4>Information</h4>' + (pro ?
'<b>State ' + pro.Statename + '</b><br />City ' + pro.Cityname + ''
: 'hover over map');;
info.addTo(map);
And to use the infobox the following three parts within the var for each layer
function infoFeatureStates(e)
var layer = e.target;
info.update(layer.feature.properties);
To empty the infobox
function resetInfoState(e)
info.update();
Eventlistener
function onEachFeatureState(feature, layer)
layer.on(
mouseover: infoFeatureState,
mouseout: resetInfoState,);
And similar functions for the other layer: infoFeatureCities, resetInfoCities, onEachFeatureCity.
When hovering over a feature from the layer States, the infobox now shows both properties, with the correct value for Statename and showing Cityname 'Undefined' as it is not a property of that layer. And vice versa when hovering over a feature from Cities layer.
I would like the info box to only be populated by the properties that are part of the selected layer (based on the feature selected by mouseover). So it doesn't show Cityname Undefined when hovering over a feature from layer States.
How do I tell the infobox with property belongs to which layer?
And how do I change which properties are shown depending on which feature (layer) is selected?
Or should I build something else completely?
leaflet
New contributor
add a comment |
I would like to use the info box as shown in the tutorial interactive choropleth map with multiple layers and properties from different layers.
The idea is to only show the properties from the selected layer.
For example the infobox has both Statename and Cityname as properties. Statename is a property in the layer States and Cityname is a property in the layer Cities.
var info = L.control(position:'topleft');
info.onAdd = function (map)
this._div = L.DomUtil.create('div', 'info');
this.update();
return this._div;;
info.update = function (pro)
this._div.innerHTML = '<h4>Information</h4>' + (pro ?
'<b>State ' + pro.Statename + '</b><br />City ' + pro.Cityname + ''
: 'hover over map');;
info.addTo(map);
And to use the infobox the following three parts within the var for each layer
function infoFeatureStates(e)
var layer = e.target;
info.update(layer.feature.properties);
To empty the infobox
function resetInfoState(e)
info.update();
Eventlistener
function onEachFeatureState(feature, layer)
layer.on(
mouseover: infoFeatureState,
mouseout: resetInfoState,);
And similar functions for the other layer: infoFeatureCities, resetInfoCities, onEachFeatureCity.
When hovering over a feature from the layer States, the infobox now shows both properties, with the correct value for Statename and showing Cityname 'Undefined' as it is not a property of that layer. And vice versa when hovering over a feature from Cities layer.
I would like the info box to only be populated by the properties that are part of the selected layer (based on the feature selected by mouseover). So it doesn't show Cityname Undefined when hovering over a feature from layer States.
How do I tell the infobox with property belongs to which layer?
And how do I change which properties are shown depending on which feature (layer) is selected?
Or should I build something else completely?
leaflet
New contributor
Seeing some of your code would be helpful in helping you.
– TomazicM
Apr 4 at 15:16
I suggest you to review these posts: 1. Leaflet: 4 overlay layers, 1 click, get properties of all intersecting polygons 2. Get all features of all layers clicked in leaflet
– Kadir Şahbaz
Apr 4 at 21:17
This may help gis.stackexchange.com/questions/315564/…, Here gistechsolutions.com/leaflet/DEMO/pointsinpoly/index.html I put results in a bootstrap dialog, but you could push them to a sidebar table or div just as easily. Just need something to like map.hasLayer() to determine if visible.
– Bill Chappell
Apr 5 at 15:43
If I understand correctly you want to show only info of topmost feature when features overlap?
– TomazicM
10 hours ago
add a comment |
I would like to use the info box as shown in the tutorial interactive choropleth map with multiple layers and properties from different layers.
The idea is to only show the properties from the selected layer.
For example the infobox has both Statename and Cityname as properties. Statename is a property in the layer States and Cityname is a property in the layer Cities.
var info = L.control(position:'topleft');
info.onAdd = function (map)
this._div = L.DomUtil.create('div', 'info');
this.update();
return this._div;;
info.update = function (pro)
this._div.innerHTML = '<h4>Information</h4>' + (pro ?
'<b>State ' + pro.Statename + '</b><br />City ' + pro.Cityname + ''
: 'hover over map');;
info.addTo(map);
And to use the infobox the following three parts within the var for each layer
function infoFeatureStates(e)
var layer = e.target;
info.update(layer.feature.properties);
To empty the infobox
function resetInfoState(e)
info.update();
Eventlistener
function onEachFeatureState(feature, layer)
layer.on(
mouseover: infoFeatureState,
mouseout: resetInfoState,);
And similar functions for the other layer: infoFeatureCities, resetInfoCities, onEachFeatureCity.
When hovering over a feature from the layer States, the infobox now shows both properties, with the correct value for Statename and showing Cityname 'Undefined' as it is not a property of that layer. And vice versa when hovering over a feature from Cities layer.
I would like the info box to only be populated by the properties that are part of the selected layer (based on the feature selected by mouseover). So it doesn't show Cityname Undefined when hovering over a feature from layer States.
How do I tell the infobox with property belongs to which layer?
And how do I change which properties are shown depending on which feature (layer) is selected?
Or should I build something else completely?
leaflet
New contributor
I would like to use the info box as shown in the tutorial interactive choropleth map with multiple layers and properties from different layers.
The idea is to only show the properties from the selected layer.
For example the infobox has both Statename and Cityname as properties. Statename is a property in the layer States and Cityname is a property in the layer Cities.
var info = L.control(position:'topleft');
info.onAdd = function (map)
this._div = L.DomUtil.create('div', 'info');
this.update();
return this._div;;
info.update = function (pro)
this._div.innerHTML = '<h4>Information</h4>' + (pro ?
'<b>State ' + pro.Statename + '</b><br />City ' + pro.Cityname + ''
: 'hover over map');;
info.addTo(map);
And to use the infobox the following three parts within the var for each layer
function infoFeatureStates(e)
var layer = e.target;
info.update(layer.feature.properties);
To empty the infobox
function resetInfoState(e)
info.update();
Eventlistener
function onEachFeatureState(feature, layer)
layer.on(
mouseover: infoFeatureState,
mouseout: resetInfoState,);
And similar functions for the other layer: infoFeatureCities, resetInfoCities, onEachFeatureCity.
When hovering over a feature from the layer States, the infobox now shows both properties, with the correct value for Statename and showing Cityname 'Undefined' as it is not a property of that layer. And vice versa when hovering over a feature from Cities layer.
I would like the info box to only be populated by the properties that are part of the selected layer (based on the feature selected by mouseover). So it doesn't show Cityname Undefined when hovering over a feature from layer States.
How do I tell the infobox with property belongs to which layer?
And how do I change which properties are shown depending on which feature (layer) is selected?
Or should I build something else completely?
leaflet
leaflet
New contributor
New contributor
edited Apr 4 at 18:56
JoeneGB
New contributor
asked Apr 4 at 14:46
JoeneGBJoeneGB
112
112
New contributor
New contributor
Seeing some of your code would be helpful in helping you.
– TomazicM
Apr 4 at 15:16
I suggest you to review these posts: 1. Leaflet: 4 overlay layers, 1 click, get properties of all intersecting polygons 2. Get all features of all layers clicked in leaflet
– Kadir Şahbaz
Apr 4 at 21:17
This may help gis.stackexchange.com/questions/315564/…, Here gistechsolutions.com/leaflet/DEMO/pointsinpoly/index.html I put results in a bootstrap dialog, but you could push them to a sidebar table or div just as easily. Just need something to like map.hasLayer() to determine if visible.
– Bill Chappell
Apr 5 at 15:43
If I understand correctly you want to show only info of topmost feature when features overlap?
– TomazicM
10 hours ago
add a comment |
Seeing some of your code would be helpful in helping you.
– TomazicM
Apr 4 at 15:16
I suggest you to review these posts: 1. Leaflet: 4 overlay layers, 1 click, get properties of all intersecting polygons 2. Get all features of all layers clicked in leaflet
– Kadir Şahbaz
Apr 4 at 21:17
This may help gis.stackexchange.com/questions/315564/…, Here gistechsolutions.com/leaflet/DEMO/pointsinpoly/index.html I put results in a bootstrap dialog, but you could push them to a sidebar table or div just as easily. Just need something to like map.hasLayer() to determine if visible.
– Bill Chappell
Apr 5 at 15:43
If I understand correctly you want to show only info of topmost feature when features overlap?
– TomazicM
10 hours ago
Seeing some of your code would be helpful in helping you.
– TomazicM
Apr 4 at 15:16
Seeing some of your code would be helpful in helping you.
– TomazicM
Apr 4 at 15:16
I suggest you to review these posts: 1. Leaflet: 4 overlay layers, 1 click, get properties of all intersecting polygons 2. Get all features of all layers clicked in leaflet
– Kadir Şahbaz
Apr 4 at 21:17
I suggest you to review these posts: 1. Leaflet: 4 overlay layers, 1 click, get properties of all intersecting polygons 2. Get all features of all layers clicked in leaflet
– Kadir Şahbaz
Apr 4 at 21:17
This may help gis.stackexchange.com/questions/315564/…, Here gistechsolutions.com/leaflet/DEMO/pointsinpoly/index.html I put results in a bootstrap dialog, but you could push them to a sidebar table or div just as easily. Just need something to like map.hasLayer() to determine if visible.
– Bill Chappell
Apr 5 at 15:43
This may help gis.stackexchange.com/questions/315564/…, Here gistechsolutions.com/leaflet/DEMO/pointsinpoly/index.html I put results in a bootstrap dialog, but you could push them to a sidebar table or div just as easily. Just need something to like map.hasLayer() to determine if visible.
– Bill Chappell
Apr 5 at 15:43
If I understand correctly you want to show only info of topmost feature when features overlap?
– TomazicM
10 hours ago
If I understand correctly you want to show only info of topmost feature when features overlap?
– TomazicM
10 hours ago
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "79"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
JoeneGB is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f317795%2fleaflet-info-box-only-showing-properties-from-selected-layer%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
JoeneGB is a new contributor. Be nice, and check out our Code of Conduct.
JoeneGB is a new contributor. Be nice, and check out our Code of Conduct.
JoeneGB is a new contributor. Be nice, and check out our Code of Conduct.
JoeneGB is a new contributor. Be nice, and check out our Code of Conduct.
Thanks for contributing an answer to Geographic Information Systems Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f317795%2fleaflet-info-box-only-showing-properties-from-selected-layer%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Seeing some of your code would be helpful in helping you.
– TomazicM
Apr 4 at 15:16
I suggest you to review these posts: 1. Leaflet: 4 overlay layers, 1 click, get properties of all intersecting polygons 2. Get all features of all layers clicked in leaflet
– Kadir Şahbaz
Apr 4 at 21:17
This may help gis.stackexchange.com/questions/315564/…, Here gistechsolutions.com/leaflet/DEMO/pointsinpoly/index.html I put results in a bootstrap dialog, but you could push them to a sidebar table or div just as easily. Just need something to like map.hasLayer() to determine if visible.
– Bill Chappell
Apr 5 at 15:43
If I understand correctly you want to show only info of topmost feature when features overlap?
– TomazicM
10 hours ago