如何使用 directionsjs 更改 Mapbox 的标记?它显示 A 和 B 标记
How do I change the marker of Mapbox with directionsjs? It shows A and B markers
如何更改 Mapbox 标记(使用 directionjs 时)?
它显示了 A 和 B 标记。
我尝试编辑标记但找不到方向。
var x= L.marker([51.508245, -0.087700], {
icon: L.mapbox.marker.icon({
'marker-size': 'large',
'marker-icon': 'monument',
'marker-color': '#fa0'
})
}).addTo(map);
// Set the origin and destination for the direction and call the routing service
directions.setOrigin(L.latLng(x));
directions.setDestination(L.latLng(51.508112, -0.075949));
directions.query();
var directionsLayer = L.mapbox.directions.layer(directions).addTo(map);
var directionsRoutesControl = L.mapbox.directions.routesControl('routes', directions)
.addTo(map);
var directionsLayer = L.mapbox.directions.layer(directions, {readonly: true}).addTo(map);
以上是我试过的,但它违反了指示。我正在寻找一种方法来更改A和B的图标。
JSFiddle:https://jsfiddle.net/x48qrca8/1/
尝试查看他们的示例,了解如何制作不同的标记样式。对于图像,check out this example,具体在这个代码:
myLayer.on('layeradd', function(e) {
var marker = e.layer,
feature = marker.feature;
marker.setIcon(L.icon(feature.properties.icon));
});
myLayer.setGeoJSON(geojson);
这将进入 GeoJSON 属性并使用 feature.properties
下的 icon
值来确定其样式。
如何更改 Mapbox 标记(使用 directionjs 时)?
它显示了 A 和 B 标记。
我尝试编辑标记但找不到方向。
var x= L.marker([51.508245, -0.087700], {
icon: L.mapbox.marker.icon({
'marker-size': 'large',
'marker-icon': 'monument',
'marker-color': '#fa0'
})
}).addTo(map);
// Set the origin and destination for the direction and call the routing service
directions.setOrigin(L.latLng(x));
directions.setDestination(L.latLng(51.508112, -0.075949));
directions.query();
var directionsLayer = L.mapbox.directions.layer(directions).addTo(map);
var directionsRoutesControl = L.mapbox.directions.routesControl('routes', directions)
.addTo(map);
var directionsLayer = L.mapbox.directions.layer(directions, {readonly: true}).addTo(map);
以上是我试过的,但它违反了指示。我正在寻找一种方法来更改A和B的图标。
JSFiddle:https://jsfiddle.net/x48qrca8/1/
尝试查看他们的示例,了解如何制作不同的标记样式。对于图像,check out this example,具体在这个代码:
myLayer.on('layeradd', function(e) {
var marker = e.layer,
feature = marker.feature;
marker.setIcon(L.icon(feature.properties.icon));
});
myLayer.setGeoJSON(geojson);
这将进入 GeoJSON 属性并使用 feature.properties
下的 icon
值来确定其样式。