0
我有是在表面上如下本地ES實例運行geoshape查詢:整合傳單GeoJSON的對象爲Elasticsearch Geoshape查詢在AngularJs
httprequest.js與geoshape查詢
spatialsearch() {
var _url = 'http://127.0.0.1:9201/_search?';
var b = {
"query": {
"bool": {
"must": {
"match_all": {}
},
"filter": {
"geo_shape": {
"metadata.o2r.spatial.geometry": {
"shape": {
"type": "polygon",
"coordinates": [
[
[-22.0, 76.0],
[-27.0, 65.0],
[-57.0, 65.0],
[-59.0, 76.0],
[-22.0, 76.0]
]
]
},
"relation": "contains"
}
}
}
}
}
};
return $http.post(_url, b);
console.log("hello");
}
目前我硬編碼的查詢座標,但我希望能夠從用戶在小葉地圖上繪製的geojson對象中獲取座標,並將它們插入到上述函數中的座標數組中。我能夠在開發控制檯中以字符串形式顯示geojson對象的座標,但是我找不到如何保存它們並在上述函數中檢索它們。 這是我如何製作geojson並在控制檯中顯示它們的座標。
search.controller.js
leafletData.getMap().then(function(map) {
leafletData.getLayers().then(function(baselayers) {
var drawnItems = baselayers.overlays.draw;
map.on('draw:created', function (e) {
var layer = e.layer;
drawnItems.addLayer(layer);
console.log(JSON.stringify(layer.toGeoJSON()));
});
});
});