Commit a545eea6 authored by PDuarte's avatar PDuarte

edit geo map UI

parent f2540d85
...@@ -10,12 +10,13 @@ import { ...@@ -10,12 +10,13 @@ import {
Rectangle, Rectangle,
TileLayer, TileLayer,
FeatureGroup, FeatureGroup,
LayerGroup,
MapContainer as LeafletMap, MapContainer as LeafletMap,
Tooltip Tooltip
} from 'react-leaflet' } from 'react-leaflet'
import { EditControl } from "react-leaflet-draw" import { EditControl } from "react-leaflet-draw"
import L from 'leaflet' import L from 'leaflet'
import { useLeafletContext } from '@react-leaflet/core' import { useLeafletContext} from '@react-leaflet/core'
import '@styles/map/leaflet.draw.css' import '@styles/map/leaflet.draw.css'
...@@ -55,6 +56,7 @@ const MapTooltip = ({gis, handleGis}) => { ...@@ -55,6 +56,7 @@ const MapTooltip = ({gis, handleGis}) => {
let numEdited = 0 let numEdited = 0
e.layers.eachLayer((layer) => { e.layers.eachLayer((layer) => {
numEdited += 1 numEdited += 1
layer._enableLayerEdit = true
console.log(layer) console.log(layer)
handleGis(layer._latlngs[0]) handleGis(layer._latlngs[0])
}) })
...@@ -117,33 +119,18 @@ const MapTooltip = ({gis, handleGis}) => { ...@@ -117,33 +119,18 @@ const MapTooltip = ({gis, handleGis}) => {
console.log('_onDeleteStop', e) console.log('_onDeleteStop', e)
} }
const _onFeatureGroupReady = (reactFGref) => { const _onFeatureGroupReady = (ref) => {
console.log(reactFGref) console.log('_onFeatureGroupReady')
// console.log(ref)
// if (ref === null) {
// return
// }
// console.log('importing service area from state')
// const leafletGeoJSON = new L.GeoJSON(gis)
// const leafletFG = ref.leafletElement
// leafletGeoJSON.eachLayer(layer => leafletFG.addLayer(layer))
} }
const showAdd = gis.length < 1
useEffect(() => {
// const test = gis + ''
}, [gis])
// const regExp = /(-?\d+(\.\d+)?)\s*(-?\d+(\.\d+)?)(,?)/
// const matches = gis.match(regExp)
// console.log(matches)
const polygon = [
[
[51.51, -0.12],
[51.51, -0.13],
[51.53, -0.13]
],
[
[51.51, -0.05],
[51.51, -0.07],
[51.53, -0.07]
]
]
const purpleOptions = { color: 'purple' } const purpleOptions = { color: 'purple' }
return ( return (
...@@ -172,13 +159,17 @@ const MapTooltip = ({gis, handleGis}) => { ...@@ -172,13 +159,17 @@ const MapTooltip = ({gis, handleGis}) => {
onDeleteStop={_onDeleteStop} onDeleteStop={_onDeleteStop}
draw={myControl} draw={myControl}
/> />
{/* <LayerGroup id="lg1"> */}
<Polygon enable={true} pathOptions={purpleOptions} positions={gis} />
{/* </LayerGroup> */}
</FeatureGroup> </FeatureGroup>
<TileLayer <TileLayer
attribution='&ampcopy <a href="http://osm.org/copyright">OpenStreetMap</a> contributors' attribution='&ampcopy <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
url='https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png' url='https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png'
/> />
<Polygon pathOptions={purpleOptions} positions={gis} />
</LeafletMap> </LeafletMap>
</CardBody> </CardBody>
</Card> </Card>
...@@ -297,7 +288,7 @@ function getGeoJson() { ...@@ -297,7 +288,7 @@ function getGeoJson() {
] ]
} }
_onFeatureGroupReady = (reactFGref) => { _onFeatureGroupReadyZ = (reactFGref) => {
// populate the leaflet FeatureGroup with the geoJson layers // populate the leaflet FeatureGroup with the geoJson layers
const leafletGeoJSON = new L.GeoJSON(getGeoJson()) const leafletGeoJSON = new L.GeoJSON(getGeoJson())
......
...@@ -137,7 +137,12 @@ const handleError = (text) => { ...@@ -137,7 +137,12 @@ const handleError = (text) => {
matches.map(point => { matches.map(point => {
const cords = point.replace(',', '').split(' ') const cords = point.replace(',', '').split(' ')
polygon.push(cords) // polygon.push(cords)
polygon.push({
lat: cords[0],
lng: cords[1]
})
console.log(cords) console.log(cords)
}) })
console.log(matches) console.log(matches)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment