Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Input data given to 'mapbox-gl-draw-cold' is not a valid GeoJSON object #21

Open
mohong opened this issue May 19, 2020 · 7 comments
Open

Comments

@mohong
Copy link

mohong commented May 19, 2020

when I change mode to 'drag_circle'……
image

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>
@cosminv6u
Copy link

I have same issue!

@iamanvesh
Copy link
Owner

@mohong Could you log the GeoJSON object and attach it here?

@mohong
Copy link
Author

mohong commented Jun 1, 2020

@mohong Could you log the GeoJSON object and attach it here?

@iamanvesh OK.

image

image

image

@bnm70
Copy link

bnm70 commented Aug 11, 2020

Any updates on this? Getting the same error with drag circle.

@OritKedem
Copy link

OritKedem commented Oct 29, 2020

Getting the same error as well

@vutrungduc7593
Copy link

This pull request resolve the issue.

#12

@Zeng-Wenquan
Copy link

CleanShot 2022-03-30 at 11 00 05@2x
change the code "coordinates:[[]]" to "coordinates: []"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants