【问题标题】:add marker using esri leaflet使用 esri 传单添加标记
【发布时间】:2018-02-01 04:42:13
【问题描述】:
我想使用 esri 传单购物车添加标记,
我使用 mapbox 添加标记的代码如下:
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);
我想通过使用 esri 传单来使用相同的东西。
请帮忙
【问题讨论】:
标签:
mapbox
esri-maps
esri-leaflet
【解决方案1】:
您可以参考以下代码使用 ESRI 传单 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);
【解决方案2】:
您可以在此处找到使用L.icon 设置点特征样式的实时 esri-leaflet 示例: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);