|
|
|
@ -66,26 +66,31 @@ export function EditLocationFilterExpression(props) { |
|
|
|
|
const { onChange, filter } = props; |
|
|
|
|
const [map, setMap] = useState(null); |
|
|
|
|
const [proposal, setProposal] = useState(filter.polygon); |
|
|
|
|
const [polyLayers, setPolyLayers] = useState([]); |
|
|
|
|
const [geoLayers, setGeoLayers] = useState([]); |
|
|
|
|
const classes = useStyles(); |
|
|
|
|
|
|
|
|
|
const _ = require('lodash'); |
|
|
|
|
|
|
|
|
|
function updateProposal(result) { |
|
|
|
|
// TODO: handle multi-polies
|
|
|
|
|
const polygon = result.geojson.coordinates[0].map(longlat => [ longlat[1], longlat[0] ]); |
|
|
|
|
|
|
|
|
|
// Show the polyline on the map
|
|
|
|
|
polyLayers.forEach(layer => { |
|
|
|
|
geoLayers.forEach(layer=> { |
|
|
|
|
map.removeLayer(layer); |
|
|
|
|
}); |
|
|
|
|
var polyline = L.polyline(polygon, { color: 'blue' }).addTo(map); |
|
|
|
|
map.flyToBounds(polyline.getBounds()); |
|
|
|
|
setPolyLayers([polyline]); |
|
|
|
|
var layer = L.geoJSON(result.geojson).addTo(map); |
|
|
|
|
map.flyToBounds(layer.getBounds()); |
|
|
|
|
setGeoLayers([layer]); |
|
|
|
|
|
|
|
|
|
// // Show the polyline on the map
|
|
|
|
|
// polyLayers.forEach(layer => {
|
|
|
|
|
// map.removeLayer(layer);
|
|
|
|
|
// });
|
|
|
|
|
// var polyline = L.polyline(polygon, { color: 'blue' }).addTo(map);
|
|
|
|
|
// map.flyToBounds(polyline.getBounds());
|
|
|
|
|
// setPolyLayers([polyline]);
|
|
|
|
|
|
|
|
|
|
// Update the proposed polygon
|
|
|
|
|
console.log("Updated proposal:", result); |
|
|
|
|
setProposal(polygon); |
|
|
|
|
// result.geojson.coordinates[0].map(longlat => [longlat[1], longlat[0]]);
|
|
|
|
|
setProposal(result.geojson); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function onSearch(query) { |
|
|
|
|