Skip to main content
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,203
24 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
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
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,351
11 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
  • 396
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

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
  • 10.3k
9 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
  • 8,130
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
  • 26.2k
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
8 votes
Accepted

Attach click function to the button inside a popup in Leaflet?

No need to use jQuery here IMHO. You can pass an HTMLElement to the bindPopup function. So just create a div and the button as javascript objects and construct the container that way. Then you can add ...
Bernd Loigge's user avatar
  • 2,840
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
  • 26.2k
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

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
  • 752
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,203
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,219
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
  • 12.6k
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
  • 16.5k
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
6 votes

Taming the text size in QGIS

A co-worker found a solution on here from a previous screen resolution issue. I just had to go to my QGIS executable and adjust the DPI settings which you can view in this question: Making icons and ...
DHWreckage's user avatar
5 votes

Changing popup position on Leaflet marker?

I know that this is an old question, but you do not need to take the detour @Robert described in his reply. As Popup is inheriting from DivOverlay, you can set the offset option directly when ...
Johannes's user avatar
  • 151
5 votes

How to let leaflet layer events to propagate to layer below

Another and perhaps better way through Leaflet code directly is to use the interactive flag. L.geoJson(gisData, { pane: 'apane', onEachFeature: someFunction, interactive: false }).addTo(...
whatsTheDiff's user avatar
5 votes

Leaflet mouseover popup makes whole map move

Leaflet displays popup box above the marker and by default wants to display the whole popup box. If box would reach outside map boundaries, map is moved to display the whole popup box. You have to use ...
TomazicM's user avatar
  • 26.2k
5 votes
Accepted

Leaflet popup - Insert image

Here is an example of the formatting just using an on-click, Note the popup is already a div, so you don't really need more divs in it. var popup = L.popup(); var photoImg = '<img src="https://...
Bill Chappell's user avatar
5 votes
Accepted

Avoiding pre-opened popups in Leaflet?

Simply remove the call of .openPopup() on your marker: var m1 = L.marker([20, 90], {icon: picture}).addTo(mymap); m1.bindPopup('<h1 class="center">Caption</h1> <br><b>Info: &...
tallistroan's user avatar
  • 2,351
5 votes
Accepted

GetFeatureInfo on mouse hover on feature in OpenLayers 3

You could simply reuse your click code and change it pointermove/hover, although I presume you only want the popup visible when over a feature, so there's an else clause to hide it. var ...
Mike's user avatar
  • 12.6k
5 votes
Accepted

Leaflet: Compare two side-by-side GeoJSON layers?

Indicated in Leaflet side by side plugin is not working with imageOverlay I changed getContainer() method with getPane() method. This method returns the HTML element representing the named pane on the ...
musedint's user avatar
5 votes

Сhanging pop-up font size in qgis2web

I tried this and it worked: <div id="map"> <div id="popup" class="ol-popup"> <a href="#" id="popup-closer" ...
OnceUponATime's user avatar

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