我想结合这些工具:Leaflet control search、leaflet-knn和Leaflet routing machine。
第一个会让我在我搜索的街道上获得一个点,第二个会找到它最近的邻居。最后一步是使用传单路由机进行导航。
在第一步之后,我需要找到如何使用点的坐标(我之前提到的街道上的那个)来完成 knn 搜索(找到最近的邻居)并最终导航到它(到最近的邻居)
我有一个 js fiddle,但我不确定我是否正确使用了它: https ://jsfiddle.net/mbatsaris/xfcs77wm/ 和这个 json 文件。任何帮助将不胜感激。谢谢你。
var camps = [
{
"type": "FeatureCollection",
"crs": { "type": "name", "properties": { "name":"urn:ogc:def:crs:OGC:1.3:CRS84" } },
"features": [
{ "type": "Feature", "properties": { "X": 748287.576139, "Y": 4187057.960012, "aa": 15299, "onoma": "3ο ΔΗΜΟΤΙΚΟ ΣΧΟΛΕΙΟ ΧΙΟΥ", "long": 26.134146, "lat": 38.377453 }, "geometry": { "type": "Point", "coordinates": [ 26.134146, 38.377453 ] } },
{ "type": "Feature", "properties": { "X": 748287.576139, "Y": 4187057.960012, "aa": 15300, "onoma": "11ο ΔΗΜΟΤΙΚΟ ΣΧΟΛΕΙΟ ΧΙΟΥ", "long": 26.136081, "lat": 38.368424 }, "geometry": { "type": "Point", "coordinates": [ 26.136081, 38.368424 ] } },
{ "type": "Feature", "properties": { "X": 748287.576139, "Y": 4187057.960012, "aa": 15301, "onoma": "4ο ΔΗΜΟΤΙΚΟ ΣΧΟΛΕΙΟ ΧΙΟΥ", "long": 26.134146, "lat": 38.377453 }, "geometry": { "type": "Point", "coordinates": [ 26.134146, 38.377453 ] } },
{ "type": "Feature", "properties": { "X": 685890.486674, "Y": 4246925.893043, "aa": 15152, "onoma": "ΓΥΜΝΑΣΙΟ ΧΙΟΥ ΕΣΠΕΡΙΝΟ", "long": 26.129116, "lat": 38.353775 }, "geometry": { "type": "Point", "coordinates": [ 26.129116, 38.353775 ] } },
{ "type": "Feature", "properties": { "X": 686171.208737, "Y": 4247801.345465, "aa": 15163, "onoma": "2ο ΕΝΙΑΙΟ ΛΥΚΕΙΟ ΧΙΟΥ", "long": 26.132558, "lat": 38.361601 }, "geometry": { "type": "Point", "coordinates": [ 26.132558, 38.361601 ] } },
{ "type": "Feature", "properties": { "X": 686175.616517, "Y": 4247807.332267, "aa": 15144, "onoma": "2ο ΓΥΜΝΑΣΙΟ ΧΙΟΥ", "long": 26.132610, "lat": 38.361654 }, "geometry": { "type": "Point", "coordinates": [ 26.13261, 38.361654 ] } },
{ "type": "Feature", "properties": { "X": 686497.839566, "Y": 4247865.195934, "aa": 15302, "onoma": "ΔΗΜΟΤΙΚΟ ΣΧΟΛΕΙΟ ΧΙΟΥ ΕΙΔΙΚΟ", "long": 26.136311, "lat": 38.362108 }, "geometry": { "type": "Point", "coordinates": [ 26.136311, 38.362108 ] } },
{ "type": "Feature", "properties": { "X": 686711.220038, "Y": 4247881.353276, "aa": 15209, "onoma": "1ο ΣΕΚ ΧΙΟΥ", "long": 26.138756, "lat": 38.362209 }, "geometry": { "type": "Point", "coordinates": [ 26.138756, 38.362209 ] } },
{ "type": "Feature", "properties": { "X": 686707.151767, "Y": 4247883.368693, "aa": 15207, "onoma": "2ο ΤΕΕ ΧΙΟΥ", "long": 26.138710, "lat": 38.362228 }, "geometry": { "type": "Point", "coordinates": [ 26.13871, 38.362228 ] } },
{ "type": "Feature", "properties": { "X": 686703.695145, "Y": 4247885.398287, "aa": 15203, "onoma": "1ο ΤΕΕ ΧΙΟΥ", "long": 26.138671, "lat": 38.362247 }, "geometry": { "type": "Point", "coordinates": [ 26.138671, 38.362247 ] } },
{ "type": "Feature", "properties": { "X": 686654.965932, "Y": 4247917.025023, "aa": 15167, "onoma": "3ο ΕΝΙΑΙΟ ΛΥΚΕΙΟ ΧΙΟΥ", "long": 26.138122, "lat": 38.362542 }, "geometry": { "type": "Point", "coordinates": [ 26.138122, 38.362542 ] } },
{ "type": "Feature", "properties": { "X": 686654.965932, "Y": 4247917.025023, "aa": 15178, "onoma": "1ο ΕΝΙΑΙΟ ΛΥΚΕΙΟ ΧΙΟΥ", "long": 26.138122, "lat": 38.362542 }, "geometry": { "type": "Point", "coordinates": [ 26.138122, 38.362542 ] } },
{ "type": "Feature", "properties": { "X": 686300.009009, "Y": 4248087.688735, "aa": 15111, "onoma": "4ο ΓΥΜΝΑΣΙΟ ΧΙΟΥ", "long": 26.134107, "lat": 38.364153 }, "geometry": { "type": "Point", "coordinates": [ 26.134107, 38.364153 ] } },
{ "type": "Feature", "properties": { "X": 686551.258503, "Y": 4248102.941494, "aa": 15393, "onoma": "ΚΕΣΥΠ ΧΙΟΥ", "long": 26.136985, "lat": 38.364238 }, "geometry": { "type": "Point", "coordinates": [ 26.136985, 38.364238 ] } },
{ "type": "Feature", "properties": { "X": 686359.882885, "Y": 4248125.937899, "aa": 15150, "onoma": "1ο ΓΥΜΝΑΣΙΟ ΧΙΟΥ", "long": 26.134802, "lat": 38.364485 }, "geometry": { "type": "Point", "coordinates": [ 26.134802, 38.364485 ] } },
{ "type": "Feature", "properties": { "X": 684887.838361, "Y": 4260691.808672, "aa": 15311, "onoma": "6ο ΔΗΜΟΤΙΚΟ ΣΧΟΛΕΙΟ ΧΙΟΥ", "long": 26.131517, "lat": 38.365979 }, "geometry": { "type": "Point", "coordinates": [ 26.131517, 38.365979 ] } },
{ "type": "Feature", "properties": { "X": 684887.838361, "Y": 4260691.808672, "aa": 15313, "onoma": "9ο ΔΗΜΟΤΙΚΟ ΣΧΟΛΕΙΟ ΧΙΟΥ", "long": 26.133857, "lat": 38.384268 }, "geometry": { "type": "Point", "coordinates": [ 26.133857, 38.384268 ] } },
{ "type": "Feature", "properties": { "X": 684887.838361, "Y": 4260691.808672, "aa": 15314, "onoma": "8ο ΔΗΜΟΤΙΚΟ ΣΧΟΛΕΙΟ ΧΙΟΥ", "long": 26.135080, "lat": 38.375425 }, "geometry": { "type": "Point", "coordinates": [ 26.13508, 38.375425 ] } },
{ "type": "Feature", "properties": { "X": 684887.838361, "Y": 4260691.808672, "aa": 15315, "onoma": "7ο ΔΗΜΟΤΙΚΟ ΣΧΟΛΕΙΟ ΧΙΟΥ", "long": 26.130533, "lat": 38.370493 }, "geometry": { "type": "Point", "coordinates": [ 26.130533, 38.370493 ] } },
{ "type": "Feature", "properties": { "X": 686111.689855, "Y": 4248328.528558, "aa": 15318, "onoma": "1ο ΔΗΜΟΤΙΚΟ ΣΧΟΛΕΙΟ ΧΙΟΥ", "long": 26.132163, "lat": 38.365841 }, "geometry": { "type": "Point", "coordinates": [ 26.132163, 38.365841 ] } },
{ "type": "Feature", "properties": { "X": 686817.400932, "Y": 4248207.323567, "aa": 15319, "onoma": "2ο ΔΗΜΟΤΙΚΟ ΣΧΟΛΕΙΟ ΧΙΟΥ", "long": 26.140098, "lat": 38.365023 }, "geometry": { "type": "Point", "coordinates": [ 26.140098, 38.365023 ] } }
]}];