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
How was Skylab's orbit inclination chosen?
Landlord wants to switch my lease to a "Land contract" to "get back at the city"
How to deal with fear of taking dependencies
Unbreakable Formation vs. Cry of the Carnarium
"To split hairs" vs "To be pedantic"
Patience, young "Padovan"
Does light intensity oscillate really fast since it is a wave?
How can I fix this gap between bookcases I made?
description of papers that have not been submitted to a venue?
It's possible to achieve negative score?
Why isn't airport relocation done gradually?
What tool would a Roman-age civilisation use to reduce/breakup silver and other metals?
The difference between dialogue marks
Is three citations per paragraph excessive for undergraduate research paper?
How are circuits which use complex ICs normally simulated?
Feasability of miniature nuclear reactors for humanoid cyborgs
Should I use my personal or workplace e-mail when registering to external websites for work purpose?
What is the use of option -o in the useradd command?
Is flight data recorder erased after every flight?
Does it makes sense to buy a new cycle to learn riding?
Does a dangling wire really electrocute me if I'm standing in water?
Is bread bad for ducks?
Why don't Unix/Linux systems traverse through directories until they find the required version of a linked library?
Why can Shazam do this?
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
JoeneGB is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
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
JoeneGB is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
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
3 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
JoeneGB is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
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
JoeneGB is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
JoeneGB is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
edited Apr 4 at 18:56
JoeneGB
New contributor
JoeneGB is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
asked Apr 4 at 14:46
JoeneGBJoeneGB
112
112
New contributor
JoeneGB is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
JoeneGB is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
JoeneGB is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
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
3 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
3 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
3 hours ago
If I understand correctly you want to show only info of topmost feature when features overlap?
– TomazicM
3 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
3 hours ago