leaflet .bindLabel using geojson feature

Greg Fiske

I am new to leaflet and I'd like to add labels to my point map features derived from geojson format.

I am getting the error: TypeError: layer.bindLabel is not a function in this script https://jsfiddle.net/gfiske/ksx600sn/35/ (uncomment line 129)

Can anyone suggest a workaround or a better approach?

thanks.

geojsonLayer = L.geoJson(geojson, {


style: function(feature) {
    return {
      color: feature.properties.GPSUserColor
    };
  },
  pointToLayer: function(feature, latlng) {
    return new L.CircleMarker(latlng, {
      radius: 7,
      fillOpacity: 0.75
    });
  },
  onEachFeature: function(feature, layer) {
    layer.bindPopup(feature.properties.MAP_LABEL);
    layer.bindLabel(feature.properties.MAP_LABEL);
    }
});
cartant

From the documentation for Leaflet.label:

NOTE: starting with Leaflet 1.0, L.Label is added to Leaflet core as L.Tooltip and this plugin is deprecrated.

You should use bindTooltip instead:

onEachFeature: function(feature, layer) {
  layer.bindPopup(feature.properties.MAP_LABEL);
  layer.bindTooltip(feature.properties.MAP_LABEL);
}

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

react-leaflet: Using a Component as a popup on a GeoJSON feature

Using getBounds on geoJSON feature

in-place Update Leaflet GeoJSON feature

Add ID to geojson feature on load in leaflet

Using fontawesome with leaflet markers and geojson

Leaflet: How to toggle GeoJSON feature properties from a single collection?

Unable to use GeoJSON using leaflet package in R

Using Geojson with tons of data in react leaflet

using Leaflet.Label with GeoJSON points

view multiple geoJSon files into view using LEaflet

loading external geojson file into leaflet map by using leaflet ajax

'Invalid GeoJSON object.' Using Leaflet and leaflet-ajax

Rendering geoJSON using D3 and Leaflet using imageOverlay

How to read a geojson file containing feature collections to leaflet-shiny directly

Multipolygons in GeoJSON file parsed with jsonlite are not visualized using leaflet

How to add markers to different layers in leaflet using onEachFeature and geojson

Add Leaflet GeoJSON layers from GeoServer to an Array using a Javascript loop

React: How to map a geojson via fetch call to state using leaflet?

How to style each Geometry of a GeoJSON GeometryCollection individually using Leaflet

How to set the marker color when using geojson.Feature

Export leaflet map to geojson

Show geojson featureCollection with Leaflet

R Leaflet GeoJSON Coloring

Leaflet GeoJson addToMap Loader

Leaflet geojson search and zoom

Leaflet MarkerCluster with GeoJson

How do you change the offset for a leaflet popup using angular leaflet directive and geojson?

Getting GeoJSON Data to Leaflet Map using ngx-leaflet, HTTPClient and Angular2+

Return Title of Closest Feature (json) Polygon using Leaflet JS