iamanvesh / mapbox-gl-draw-circle Goto Github PK
View Code? Open in Web Editor NEWSupports drawing/editing a circle on a Mapbox map.
Home Page: https://iamanvesh.github.io/mapbox-gl-draw-circle-test/
License: MIT License
Supports drawing/editing a circle on a Mapbox map.
Home Page: https://iamanvesh.github.io/mapbox-gl-draw-circle-test/
License: MIT License
How to get the liveradius when creating the circle?
When I drag the circle for creating it has to show me the live radius of the circle.
Can anyone please help me with this ASAP.
In recently updated my project mapbox-gl-draw version to 1.2.0, but it causes me errors with mapbox-gl-draw-circle module because its currently using mapbox-gl 1.1.1 version
I have implemented, circlet modes into my mapboxDraw, and I have created a button to call the circle Draw function , but I dont know how to that , what function should I put when "onClick()"
any help please
Is there any way to customize the circle? By customization: I mean to change the color. Is there any way as well to disable the creation of circle by click so that I can add multiple circles on the map?
Hello!
I'm getting this error when trying to build my project in Azure Pipelines:
Module not found: Error: Can't resolve '@mapbox/mapbox-gl-draw/src/constants' in '/home/vsts/work/1/s/node_modules/mapbox-gl-draw-rounded-circle/lib/modes'
I'm using "mapbox-gl-draw-rounded-circle": "^2.1.0", "@mapbox/mapbox-gl-draw": "^1.3.0", and node 18.x
Can you help me?
This question is more from a feature of Leaflet draw library comparison. In that, you can draw a circle by hold and drag to decide center and radius of the circle. In this library's implementation, you have to draw the circle by specifying an initial radius and then change it to modify the circle radius.
Is there a way to decide radius upfront instead of changing it afterward
I would like to add a non editable circle with a specified lat/lon and radius programmatically and clicking on the circle should make it editable.
Is this currently possible with this library?
Hi,
I just updated the packages and received a new error:
/node_modules/mapbox-gl-draw-circle/lib/modes/CircleMode.js
Module parse failed: Unexpected token (6:20)
You may need an appropriate loader to handle this file type.
| const circle = require('@turf/circle').default;
|
| const CircleMode = {...MapboxDraw.modes.draw_polygon};
| const DEFAULT_RADIUS_IN_KM = 2;
|
In my actual code, I am getting this error when I try to import it:
module "/home/user/workspace/node_modules/mapbox-gl-draw-circle/index" Could not find
a declaration file for module 'mapbox-gl-draw-circle'.
'/home/user/workspace/node_modules/mapbox-gl-draw-circle/index.js' implicitly
has an 'any' type.
Try `npm install @types/mapbox-gl-draw-circle` if it exists or add a new declaration
(.d.ts) file containing `declare module 'mapbox-gl-draw-circle';`ts(7016)
I wanted to check and see if I was the only one receiving these errors or if my build somehow got screwed up. I did update the other modules that mapbox-gl-draw-circle
uses but it didn't work.
Hi,
I just add the packages and received error:
ERROR in ../../node_modules/jsonlint-lines/lib/jsonlint.js 692:17-43
Module not found: Error: Can't resolve 'fs' in 'D:\workspace\webapp\node_modules\jsonlint-lines\lib'
@ ../../node_modules/@mapbox/geojsonhint/lib/index.js 1:15-40
@ ../../node_modules/mapbox-gl-draw-circle/node_modules/@mapbox/mapbox-gl-draw/src/api.js 6:20-50
@ ../../node_modules/mapbox-gl-draw-circle/node_modules/@mapbox/mapbox-gl-draw/index.js 3:17-37
@ ../../node_modules/mapbox-gl-draw-circle/lib/modes/SimpleSelectModeOverride.js 1:19-52
@ ../../node_modules/mapbox-gl-draw-circle/index.js 4:32-79
@ ../../src-components/components/BasicMapProvider.tsx 17:0-79 196:21-31 197:21-35 198:23-33 @ ../../src-components/components/FeatureEditor.tsx 12:0-62 92:32-48 99:22-28
@ ./sentry/overview/index.tsx 3:0-79 70:37-57
@ ./sentry/overview/route.ts 2:0-30 7:13-21
@ ./sentry/route.ts 4:0-45 8:129-142
@ ./route.tsx 6:0-42 17:40-52
@ ./bootstrap.tsx 6:0-32 80:9-14
@ ./index.ts 2:0-40 3:0-9
How do you show the radius directly to the drawn circle?
import MapboxDraw from "@mapbox/mapbox-gl-draw";
import { CircleMode, DirectMode, DragCircleMode, SimpleSelectMode } from "mapbox-gl-draw-circle";
const draw = new MapboxDraw({
displayControlsDefault: false,
defaultMode: "draw_circle",
userProperties: true,
modes: {
...MapboxDraw.modes,
draw_circle: CircleMode,
drag_circle: DragCircleMode,
direct_select: DirectMode,
simple_select: SimpleSelectMode
}
});
draw.changeMode("draw_circle", { initialRadiusKm: 0.001 });
leads to the following error: TypeError: Cannot read properties of undefined (reading 'changeMode')
Hello,
I'm looking for how can I add the draw circle control to my map control.
I have this code
const draw = new MapboxDraw({
displayControlsDefault: true,
userProperties: true,
defaultMode: 'draw_circle',
modes: {
...MapboxDraw.modes,
draw_circle : CircleMode,
drag_circle : DragCircleMode,
direct_select: DirectMode,
simple_select: SimpleSelectMode
}
});
And when I switch to draw polygon, I can't switch to draw circle again because I don't have it in my Map control
I want to change radius of circle by inputting value. Is it posssible and how can I do this? Thank you! (I use mapboxgl)
Hi!
Is there any way to use this as script link file from CDN? Tried using unpkg.com, but get errors saying that "CircleMode" is undefined.
Hi,
When using the package with angular 9, it doesn't work, I have this error :
ERROR in ./node_modules/jsonlint-lines/lib/jsonlint.js
Module not found: Error: Can't resolve 'fs' in 'C:\Workspace\COVAL-web\node_modules\jsonlint-lines\lib'
Any help please?
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 installed and then imported the modules as shown in the docs. Then the below happened:
ERROR in ./node_modules/jsonlint-lines/lib/jsonlint.js 942:44-69
Module not found: Error: Can't resolve 'path' in '/Users/scientist/Documents/GitHub/msc-project/client/node_modules/jsonlint-lines/lib'
BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.
If you want to include a polyfill, you need to:
- add a fallback 'resolve.fallback: { "path": require.resolve("path-browserify") }'
- install 'path-browserify'
If you don't want to include a polyfill, you can use an empty module like this:
resolve.fallback: { "path": false }
I also get another error as expressed here.
For people that need this functionality urgently, I recommend mapbox-gl-draw-geodesic. I do have to say though I am confused with the documentation of this one.
Hi, I am using both mapbox-gl-draw-circle and mapbox-gl-draw.
I was curious to know if it is possible to switch between circles and polygons without having to alter any code to make it switch. For instance, you could make the polygon button draw a polygon while the marker button draws a circle.
Does anyone know if this is possible? I'm open to any options. Thanks!
Is there any update on updating mapbox-gl-draw to a more recent version #27 (comment)? There seems to be an npm audit warning with one of it's dependencies in version 1.1.1. Thank you!
I add some draw mode to my program, when user click one type, they can draw corresponding shape on the map. But the 'draw_polygon' mode draw the same shape as 'draw_circle ' mode, can you tell me how to solve this conflicts?
map.on('load', e => {
// userProperties has to be enabled
var draw = new MapboxDraw({
modes: {
...MapboxDraw.modes,
draw_circle: CircleMode,
direct_select: DirectMode,
simple_select: SimpleSelectMode,
draw_rectangle: DrawRectangle,
lots_of_points: LotsOfPointsMode
},
displayControlsDefault: false
});
// Add this draw object to the map when map loads
map.addControl(draw);
window.drawTypeHandler = function(type) {
switch(type) {
case 1: draw.changeMode('draw_point');break;
case 2: draw.changeMode('draw_line_string');break;
case 3: draw.changeMode('draw_polygon');break;
case 4: draw.changeMode('draw_rectangle');break;
case 5: draw.changeMode('draw_circle');break;
}
}
});
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.