mapbox-gl-draw-circle
mapbox-gl-draw-circle copied to clipboard
Input data given to 'mapbox-gl-draw-cold' is not a valid GeoJSON object
when I change mode to 'drag_circle'……
dependents:
"@mapbox/mapbox-gl-draw": "^1.1.2",
"core-js": "^3.6.4",
"gl-draw-foxgis": "github:wanyanyan/gl-draw-foxgis",
"mapbox-gl": "^1.10.1",
"mapbox-gl-draw-circle": "^1.1.1",
"vue": "^2.6.11",
"vue-router": "^3.1.6"
vue code:
<template>
<div class="mapbox">
<div id="map"></div>
<button @click="drawCircle">画圆</button>
</div>
</template>
<script>
import mapboxgl from 'mapbox-gl';
import Draw from '@mapbox/mapbox-gl-draw'
import { CircleMode, DragCircleMode, DirectMode, SimpleSelectMode } from 'mapbox-gl-draw-circle'
mapboxgl.accessToken = 'my token';
export default {
name: 'mapbox',
mounted () {
this.map = null
this.draw = null
this.initMap()
},
methods: {
initMap () {
const map = new mapboxgl.Map({
container: 'map',
zoom: 10,
style: 'mapbox://styles/mapbox/streets-v9'
});
map.on('load', () => {
console.log('load')
this.map = map
this.initDraw(map)
})
},
initDraw (map) {
this.draw = new Draw({
userProperties: true,
displayControlsDefault: false,
modes: {
...Draw.modes,
draw_circle: CircleMode,
drag_circle: DragCircleMode,
direct_select: DirectMode,
simple_select: SimpleSelectMode
}
})
map.addControl(this.draw)
},
drawCircle () {
this.draw.changeMode('drag_circle')
}
}
}
</script>
<style scoped lang="stylus">
#map
height 500px
</style>
I have same issue!
@mohong Could you log the GeoJSON object and attach it here?
@mohong Could you log the GeoJSON object and attach it here?
@iamanvesh OK.
Any updates on this? Getting the same error with drag circle.
Getting the same error as well
This pull request resolve the issue.
https://github.com/iamanvesh/mapbox-gl-draw-circle/pull/12
change the code "coordinates:[[]]" to "coordinates: []"