As of May 31, 2023, we have updated our Code of Conduct.

Hot answers tagged

30 votes

Displaying properties of GeoJSON in popup on Leaflet?

The line where you create and bind your popup should have been included in the onEachFeature option of your L.geoJSON factory. var layerGroup = L.geoJSON(data, { onEachFeature: function (feature, ...
ghybs's user avatar
  • 7,073
22 votes

How to update a popup content from its marker?

_popup has an underscore in front of it to indicate that it's a private / member instance, and should not be accessed directly. The correct API is Layer.setPopupContent(). e.g. marker.setPopupContent(...
ericsoco's user avatar
  • 323
18 votes

Showing popup on mouse-over, not on click using Leaflet?

If you're using Leaflet 1.3.x, tooltip binding is a built in method. http://leafletjs.com/reference-1.3.0.html#tooltip var polyline = L.polyline([[StartLat, StartLong],[EndLat,EndLong]]).addTo(this....
Fully Stuck Developer's user avatar
15 votes
Accepted

Custom marker and properties from geoJSON in Leaflet

To create a custom marker you can create a L.Icon object and for the popup you can use the onEachFeature option. Here is an example code snippet for these functions: var myIcon = L.icon({ iconUrl: ...
tallistroan's user avatar
  • 2,341
14 votes
Accepted

How to update a popup content from its marker?

I suppose you want the content to be changed after some event occured, like mouseover, contextmenu, or anything else. To do so, you can use the following code: //marker creation var marker = L....
Alexandru Pufan's user avatar
14 votes
Accepted

Error when trying to bind popup on geojson, failed to execute 'appendChild'

I had the exact same problem and it solved when I concatenated a string to it. // the number shows correctly itself console.log(layer.feature.properties.ROWID); // 46 // but bindPopup() won't accept ...
Florian Boudot's user avatar
11 votes
Accepted

Styling popup with two separate styles at once in Leaflet

I have no idea what the error means, but you can make a circle and a semicircle, then, combine them in a featureGroup. var map = L.map('map').setView([39, 30], 7); L.tileLayer('https://api.mapbox.com/...
Kadir Şahbaz's user avatar
10 votes
Accepted

Handling Popups in Leaflet with Overlapping Features?

One option would be to use leaflet point in poly (leaflet.pip) which is available through Mapbox: https://www.mapbox.com/mapbox.js/example/v1.0.0/point-in-polygon/ Or as a leaflet plugin: https://...
user3103373's user avatar
10 votes

Displaying properties of GeoJSON in popup on Leaflet?

Build a simple popup content for any properties in a simple way, in one line: var layer = L.geoJSON(data, { onEachFeature: function (f, l) { l.bindPopup('<pre>'+JSON.stringify(f.properties,...
stefcud's user avatar
  • 386
10 votes
Accepted

Why does the className option of a Leaflet popup change only the outside of the popup?

A popup in Leaflet is not one single HTMLElement. If you use the developer tools in your web browser, you'll see that a popup has: A container for the whole thing: (note how there's a margin on the ...
IvanSanchez's user avatar
  • 9,915
9 votes
Accepted

Submit a form from within a leaflet popup?

I figured it out! - the problem is that my function or wherever I hold my line of code to "preventDefault()" was outside of the function that created the form in the first place. I need to place the ...
Stella's user avatar
  • 1,300
9 votes
Accepted

Adding popup to Leaflet but only on click?

Just leave out call of .openPopup() method: mymarker.bindPopup('<p>You are here ' + username + '</p>');
TomazicM's user avatar
  • 21.5k
8 votes
Accepted

how can I specify a popup to show only for a specific layer in openLayers 3?

When doing forEachFeatureAtPixel, you should do any filtrering inside the callback function. You have the feature and it's layer available as arguments. This would return the first clicked feature: ...
Alvin Lindstam's user avatar
8 votes
Accepted

Access report/atlas page from feature in layer (QGIS)

The identify tool could do what you expect in possibility number 1. It could open the atlas page you click on. Step by step : Select the layer used as coverage layer Click on the identify tool Right-...
Corentin Lemaitre's user avatar
7 votes

Getting image pop ups in QGIS

Like Maj said, I think that he easiest way to do something like you said is based om the map tips functionality. You can find the steps by step description here First you should have a file name or a ...
Obi Wan's user avatar
  • 237
7 votes
Accepted

How do I show feature attributes in a Leaflet popup?

Look at the docs! You'll see that you need to define other callback methods on the L.geoJson object. Namely: L.geoJson(data, { style: function (feature) { return {[style properties here}; ...
Stev_k's user avatar
  • 6,596
7 votes
Accepted

OpenLayers 3.10.1 - Feature Popup

This works on OL 3.10.1. This example assumes you already have a feature layer added to your map and are using bootstrap and Jquery. For a solution without Jquery and Bootstrap see : OpenLayers 3 - ...
Alexis_A's user avatar
  • 726
7 votes
Accepted

Automating Pop up configuration of web app in ArcGIS for Portal?

If you're using Portal for ArcGIS or ArcGIS Online you can manage your configuration files via the ArcGIS Online Assistant. Login with your Portal or ArcGIS Online credentials and select 'View an Item'...
Radar's user avatar
  • 10.7k
7 votes
Accepted

How to add top and bottom margins to leaflet popup with scroll

I couldn't get your strategy that both custom-popup and leaflet-popup-content-wrapper style classes have overflow: auto property to work properly. I moved overflow: auto property to leaflet-popup-...
TomazicM's user avatar
  • 21.5k
6 votes

Getting image pop ups in QGIS

At 3.8.0, here's what works for me: Create a point layer (Geopackage, shape file, etc) Create a text attribute field in the point layer: call it, say, image_path A reasonable maximum length is 320 ...
Stu Smith's user avatar
  • 7,649
6 votes

Moveable ArcGIS Identify Popup Window (Dojo)

This blog has an excellent example of how to make the window draggable and hide the arrow using dojo: https://gavinr.com/2015/04/13/arcgis-javascript-draggable-infowindow Here's the key javascript ...
Chris's user avatar
  • 431
6 votes

How to get a pop up in QGIS when clicking on points on a map

Ok two things here I think. Getting information for a point and creating a shapefile. Information. There is a tool called "Identify Features" which is a point that allows you to bring up a window ...
Will Hore-Lacy's user avatar
6 votes

Changing popup position on Leaflet marker?

You can specify the offsets by using the popupAnchor options, but not where you would expect it. First, you need to specify an icon like this: var myIcon = L.divIcon({ popupAnchor: [0, -30] }); You ...
Rob's user avatar
  • 161
6 votes
Accepted

OpenLayers 3 - Feature Popup without Jquery/Bootstrap

This works on OL 3.20.1. This example assumes you already have a feature layer added to your map. HTML <div id="map" class="map"><div id="info"></div></div> CSS #map { ...
Alexis_A's user avatar
  • 726
6 votes
Accepted

Changing data and style with <select> in Leaflet popup

From the code you provide in your JSFiddle: function onEachFeature(feature, layer) { var popup = '<select name="select" onchange="restyleLayer(this.value)">' popup += '<option value="...
ghybs's user avatar
  • 7,073
6 votes
Accepted

Combining popup info from overlapping polygons in Mapbox GL JS

Within your map.on('click') callback, e.features is an array of all features from testlayer at the point clicked. So instead of only choosing the first in your popup, you can display all values like ...
AndrewHarvey's user avatar
  • 2,179
6 votes
Accepted

Multiple popup styles for Leaflet

You should assign a different classname and define the relative CSS style for each kind of popup: var popup = L.popup({ closeButton: true, autoClose: true, className: "custom-popup" // ...
Antonio Falciano's user avatar
6 votes

Add a polygon programmatically in OpenLayers 3?

Polygon geometry needs two additional pairs of brackets geometry: new ol.geom.Polygon([[[8623931.28, 1449016.75],[8624007.72, 1458265.63], [8629358.31, 1458571.37],[8628441.06, ...
Mike's user avatar
  • 11.8k
6 votes
Accepted

How do I stop the identify results popup window in QGIS 3

Using QGIS 3.10, you may click on the small wrench-icon in the icon-panel at the top of the identify-tool window (see screenshot). Make sure the (only) option is deactivated. The documentation for 3....
Erik's user avatar
  • 15.1k
6 votes

Variable nested inside another variable not displayed properly in popup in Leaflet

You missed innerHTML in else, and you should change + stream to + innerHTML in setContent. Use this: onEachFeature: function (pointFeature, layer) { var stream = pointFeature.properties.Stream; ...
Kadir Şahbaz's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible