在具有 mapbox 或类似方向的地方之间路由 api
Routing between places with mapbox or similar direction api
我有一个 geoJSON 对象,我想在我的 geoJSON 文件上的 waypoints 之间进行路由。
{
"type":"FeatureCollection",
"generator":"JOSM",
"bbox":[
23.4668,
58.9198,
23.6412,
58.974
],
"features":[
{
"type":"Feature",
"properties":{
"wheelchair":"yes",
"smoothness":"bad",
"surface":"crushed stones"
},
"geometry":{
"type":"Point",
"coordinates":[
23.53359252,
58.95034587858
]
}
},
{
"type":"Feature",
"properties":{
"wheelchair":"yes",
"addr:housename":"Saue kohvik",
"amenity":"pub",
"name":"Saue kohvik"
},
"geometry":{
"type":"Point",
"coordinates":[
23.5361382,
58.9473236
]
}
},
{
"type":"Feature",
"properties":{
"wheelchair":"yes",
"smoothness":"intermediate",
"highway":"footway"
},
"geometry":{
"type":"LineString",
"coordinates":[
[
23.5410658,
58.9406213
],
[
23.5410936,
58.9408252
],
[
23.541092,
58.9408358
],
[
23.5410706,
58.9410896
],
[
23.5410448,
58.9412609
],
[
23.541028,
58.9413309
],
[
23.5409993,
58.9414512
],
[
23.5408984,
58.9416477
],
[
23.5408677,
58.9416962
],
[
23.5407571,
58.9418706
],
[
23.5405886,
58.9421204
],
[
23.5405302,
58.9422071
],
[
23.5403894,
58.9423888
],
[
23.5401636,
58.9426413
],
[
23.5400953,
58.9426593
],
[
23.5399336,
58.9428447
],
[
23.5399287,
58.9428504
],
[
23.5399434,
58.9428895
],
[
23.5394702,
58.9434341
],
[
23.5394296,
58.943468
],
[
23.5389324,
58.9439879
],
[
23.5384256,
58.9445103
],
[
23.5381597,
58.9447992
],
[
23.5377425,
58.9452314
],
[
23.5375449,
58.9454551
]
]
}
},
{
"type":"Feature",
"properties":{
"wheelchair":"yes",
"highway":"footway"
},
"geometry":{
"type":"LineString",
"coordinates":[
[
23.5408677,
58.9416962
],
[
23.541045,
58.9417267
],
[
23.5412157,
58.9417564
]
]
}
}
]
}
我的问题是:我可以在我的文件 "routing only on these LineStrings where properties are "wheelchair":"yes" 和 "highway":"footway" 中的位置之间进行路由吗?路由不能使用 LineStrings where 属性 只是 "highway":"footway".
当我使用 mapbox 导航服务时可以吗?
我用我的自定义属性制作了自己的 openstreetmap,但我知道我卡住了,我不知道如何在该地图中进行路由,因为路由只能调用这些方式(线串和点)其中一个属性是轮椅="yes".
您可以使用 L.mapbox.FeatureLayer
结合过滤器呈现您的特征集合:
var featureLayer = L.mapbox.featureLayer('data.geo.json').addTo(map);
var filter = function (feature) {
// Check if feature is a linestring
if (feature.geometry.type == 'Linestring') {
// Check if has property wheelchair and value is yes
if (feature.properties.hasOwnProperty('wheelchair') &&
feature.properties.wheelchair === 'yes') {
// Check if has property highway and value is footway
if (!feature.properties.hasOwnProperty('highway') ||
feature.properties.highway === 'footway') {
// highway absent or highway is footway
return true;
} else {
// highway found and value is not footway
return false;
}
} else {
// Wheelchair absent or value isn't yes
return false;
}
} else {
// Not a linestring
return true;
}
}
featureLayer.on('ready', function () {
featureLayer.setFilter(filter);
});
参考 L.mapbox.featureLayer
:https://www.mapbox.com/mapbox.js/api/v2.1.5/l-mapbox-featurelayer/
我有一个 geoJSON 对象,我想在我的 geoJSON 文件上的 waypoints 之间进行路由。
{
"type":"FeatureCollection",
"generator":"JOSM",
"bbox":[
23.4668,
58.9198,
23.6412,
58.974
],
"features":[
{
"type":"Feature",
"properties":{
"wheelchair":"yes",
"smoothness":"bad",
"surface":"crushed stones"
},
"geometry":{
"type":"Point",
"coordinates":[
23.53359252,
58.95034587858
]
}
},
{
"type":"Feature",
"properties":{
"wheelchair":"yes",
"addr:housename":"Saue kohvik",
"amenity":"pub",
"name":"Saue kohvik"
},
"geometry":{
"type":"Point",
"coordinates":[
23.5361382,
58.9473236
]
}
},
{
"type":"Feature",
"properties":{
"wheelchair":"yes",
"smoothness":"intermediate",
"highway":"footway"
},
"geometry":{
"type":"LineString",
"coordinates":[
[
23.5410658,
58.9406213
],
[
23.5410936,
58.9408252
],
[
23.541092,
58.9408358
],
[
23.5410706,
58.9410896
],
[
23.5410448,
58.9412609
],
[
23.541028,
58.9413309
],
[
23.5409993,
58.9414512
],
[
23.5408984,
58.9416477
],
[
23.5408677,
58.9416962
],
[
23.5407571,
58.9418706
],
[
23.5405886,
58.9421204
],
[
23.5405302,
58.9422071
],
[
23.5403894,
58.9423888
],
[
23.5401636,
58.9426413
],
[
23.5400953,
58.9426593
],
[
23.5399336,
58.9428447
],
[
23.5399287,
58.9428504
],
[
23.5399434,
58.9428895
],
[
23.5394702,
58.9434341
],
[
23.5394296,
58.943468
],
[
23.5389324,
58.9439879
],
[
23.5384256,
58.9445103
],
[
23.5381597,
58.9447992
],
[
23.5377425,
58.9452314
],
[
23.5375449,
58.9454551
]
]
}
},
{
"type":"Feature",
"properties":{
"wheelchair":"yes",
"highway":"footway"
},
"geometry":{
"type":"LineString",
"coordinates":[
[
23.5408677,
58.9416962
],
[
23.541045,
58.9417267
],
[
23.5412157,
58.9417564
]
]
}
}
]
}
我的问题是:我可以在我的文件 "routing only on these LineStrings where properties are "wheelchair":"yes" 和 "highway":"footway" 中的位置之间进行路由吗?路由不能使用 LineStrings where 属性 只是 "highway":"footway".
当我使用 mapbox 导航服务时可以吗?
我用我的自定义属性制作了自己的 openstreetmap,但我知道我卡住了,我不知道如何在该地图中进行路由,因为路由只能调用这些方式(线串和点)其中一个属性是轮椅="yes".
您可以使用 L.mapbox.FeatureLayer
结合过滤器呈现您的特征集合:
var featureLayer = L.mapbox.featureLayer('data.geo.json').addTo(map);
var filter = function (feature) {
// Check if feature is a linestring
if (feature.geometry.type == 'Linestring') {
// Check if has property wheelchair and value is yes
if (feature.properties.hasOwnProperty('wheelchair') &&
feature.properties.wheelchair === 'yes') {
// Check if has property highway and value is footway
if (!feature.properties.hasOwnProperty('highway') ||
feature.properties.highway === 'footway') {
// highway absent or highway is footway
return true;
} else {
// highway found and value is not footway
return false;
}
} else {
// Wheelchair absent or value isn't yes
return false;
}
} else {
// Not a linestring
return true;
}
}
featureLayer.on('ready', function () {
featureLayer.setFilter(filter);
});
参考 L.mapbox.featureLayer
:https://www.mapbox.com/mapbox.js/api/v2.1.5/l-mapbox-featurelayer/