0

I want to add a marker using esri leaflet cart,

My code to add a marker using mapbox is given as follow:

  var marker = L.marker(new L.LatLng(lat, long), {
        icon: L.mapbox.marker.icon({
            'marker-color': 'ff8888'
        }),
        draggable: true
        });
       marker.bindPopup('adresse');
        marker.addTo(map);

I want to use the same thing by using esri leaflet.

any help please

Majdi Taleb
  • 731
  • 3
  • 9
  • 26

2 Answers2

0

You can refer the following piece of code to draw a point using ESRI leaflet API.

var map = L.map('map').setView([37.837, -122.479], 8);

  L.esri.basemapLayer('Streets').addTo(map);

  var icon = L.icon({
    iconUrl: 'https://esri.github.io/esri-leaflet/img/earthquake-icon.png',
    iconSize: [27, 31],
    iconAnchor: [13.5, 17.5],
    popupAnchor: [0, -11]
  });

  L.esri.featureLayer({
    url: 'https://sampleserver6.arcgisonline.com/arcgis/rest/services/Earthquakes_Since1970/MapServer/0',
    pointToLayer: function (geojson, latlng) {
      return L.marker(latlng, {
        icon: icon
      });
    }
  }).addTo(map);
vivek shukla
  • 56
  • 1
  • 4
-1

you can find a live esri-leaflet example that styles point features using L.icon here: http://esri.github.io/esri-leaflet/examples/styling-feature-layer-points.html

L.esri.featureLayer({
  url: 'https://services.arcgis.com/rOo16HdIMeOBI4Mb/arcgis/rest/services/Trimet_Transit_Stops/FeatureServer/0',
  pointToLayer: function (geojson, latlng) {
    return L.marker(latlng, {
      icon: L.icon({
        iconUrl: 'https://esri.github.io/esri-leaflet/img/bus-stop-north.png'
      })
    });
  },
}).addTo(map);
john gravois
  • 392
  • 2
  • 8