smithmicro / mapbox-gl-circle Goto Github PK
View Code? Open in Web Editor NEWA *google.maps.Circle* replacement for Mapbox GL JS
Home Page: https://smithmicro.github.io/mapbox-gl-circle/
License: ISC License
A *google.maps.Circle* replacement for Mapbox GL JS
Home Page: https://smithmicro.github.io/mapbox-gl-circle/
License: ISC License
When the Jenkinsfile produces an artifact, the name should include current version number from package.json
When interacting with the circle in Firefox, performance is rather sluggish.
I want to show/hide the circles, maybe using a classname or ID.
Is this possible? (Sorry for opening an issue, I didn't see any other resources available).
Thanks-
Is there a need to have optionalDependencies
? Our installation procedure always tries to install them regardless of no-optional
flag in npm, but I was wondering is there any particular reason you ship package.json with that property? Could it be removed or transferred to devDependencies
since itβs mostly build stuff like Yarn?
Sometimes the drag operation does not end in a "mouseup", e.g. when drag ends outside the document or cmd-shifting to another application during drag. Circle logic should handle this as a dragend.
click
event with target circle as first callback argument.contextmenu
event with target circle as first callback argument.ctrl + left-click
combo that some old Mac users might use as means of right-clicking, it should also fire a contextmenu
event (and suppress the "normal" click)What's a good way to show the radius of a circle
I don't like using IE either, but I need to support it.
Using the demo in IE (https://smithmicro.github.io/mapbox-gl-circle/) is very slow
Hi @mblomdahl
I was wondering if this repo is still maintained. Can see some some critical open PR s still not merged.
Thanks
I get some strange lines that span the circle at various points that shift based on zoom level. However, they seem to disappear above zoom level 16 or there abouts.
const areaCircle = new MapboxCircle({ lat: 42.2446, lng: -70.9623 }, 804, { strokeColor: '#ffffff', strokeWeight: 5, fillOpacity: 0, }).addTo(map);
Hey guys,
I've noticed that there is an issue while moving with circle while there are also some other elements placed on the map, like markers. When you move across these elements it will stop dragging the circle, I've prepared codepen example so you can check it out. I think that issue exists there from version 1.4.0, I'm using version 1.3.0 for now as it's working fine there.
When creating a circle with option editable: false
, the setting is ignored. Correct behavior would be to draw a circle without the handles and event listeners.
When hovering over a radius handle, before dragging:
When dragging a handle to adjust radius:
hey guys,
we are using your library in 1 project,
however we faced an issue when trying to deploy to production,
in create-react-app project we are not able to build it,
it's saying it's app.js line 43, but I cannot figure out what's wrong there,
would be great if you can fix it,
thanks,
Greg
Hi, I started implementing mapbox-gl-circle into a program that has several other layers on the map and noticed that the circle always appeared behind one of my other layers, regardless of what order they were added in.
I tracked it down to these lines in the code where waterway-label
is hardcoded as the second argument to addLayer
causing the circle to always be added just before this layer.
You can see the issue in action here:
It's pretty straightforward to expose the before
argument to the user so that users can control where a circle is added in the layer stack. I implemented a fix as you can see in this image.
Here's my pull request for the proposed fix https://github.com/mblomdahl/mapbox-gl-circle/pull/51
Thanks!
Add usage instructions when not relying on require(...) (standalone script load) + test that it actually works as NPM dependency for third-party libraries.
When the Jenkinsfile produces an artifact, the name should include current git branch and build number.
Initially brought up during review of PR #86, the current CI/CD via Jenkins is broken and needs a replacement to continue structured and robust maintenance of this repository.
Draft acceptance criterion:
NPM_TOKEN = credentials('mblomdahl_npm')
secret in Jenkinsfile L#131release/x.y.z
branch should push a release candidate to NPMmaster
branch should push a release to NPMPing @gleite-smsi FYI!
Evaluate impact of using Ryan Baumann's debounce tip from mapbox/smithmicro-collab#1, map.on('mousemove', _.debounce(onMousemove, 12, {trailing: true, leading: true}))
.
When attempting to update GL JS version from 0.40.1 to 0.44.1, we found that the style-layer switching no longer works.
How it was (successfully) handled in the latest mapbox-gl-circle version:
styledataloading
upon being added to a mapstyledata
firingstyledata
firing, the circle would add itself back to the mapWas working really well.
Here's the code that does it:
class MapboxCircle {
/* snip */
/**
* When map style is changed, remove circle assets from map and add it back on next MapboxGL 'styledata' event.
* @param {MapDataEvent} event
* @private
*/
_onMapStyleDataLoading(event) {
if (this.map) {
this.map.once('styledata', () => {
// noinspection JSUnresolvedVariable
this.addTo(event.target);
});
this.remove();
}
}
/* snip */
addTo(map, before) {
const addCircleAssetsOnMap = () => {
/* snip */
map.on('styledataloading', this._onMapStyleDataLoading);
/* snip */
}
/* snip */
/**
* Remove source data, layers and listeners from map.
* @return {MapboxCircle}
* @public
*/
remove() {
this.map.off('styledataloading', this._onMapStyleDataLoading);
this.observer.disconnect();
if (this.options.editable) {
this._unbindBroadcastListeners();
MapboxCircle._removeActiveEditableCircle(this);
this.off('radiuschanged', this._onRadiusChanged).off('centerchanged', this._onCenterChanged);
this._unbindRadiusHandlesListeners();
this.map.removeLayer(this._circleRadiusHandlesId);
this._unbindCenterHandleListeners();
this.map.removeLayer(this._circleCenterHandleId);
this.map.removeSource(this._circleRadiusHandlesSourceId);
this.map.removeSource(this._circleCenterHandleSourceId);
}
this.map.off('zoomend', this._onZoomEnd);
this._unbindCircleFillListeners();
this.map.removeLayer(this._circleFillId);
this.map.removeLayer(this._circleStrokeId);
this.map.removeSource(this._circleSourceId);
this.map = null;
return this;
}
/* snip */
}
What happens with the latest version is that remove() call fails because, apparently, the circle assets already does not exist.
Question: @ryanbaumann is there some earlier event we should listen to in order to detect-and-handle a style layer change?
Import repo:
import MapboxCircle from 'mapbox-gl-circle';
Summary:
Run Webpack to build the codebase with Webpack's UglifyJsPlugin
on. Webpack is attempting to minify all the files in the codebase, but cannot handle ES6 code, resulting in an error.
Error:
ERROR in <file>.js from UglifyJs Unexpected token: name (MapboxCircle)
Workaround:
import MapboxCircle from 'mapbox-gl-circle/dist/mapbox-gl-circle.min.js'
Importing the minified file seems to be an acceptable workaround for the time being.
Solution:
I don't believe this is limited to Webpack. I'm guessing any minification would result in this error. ES6 code could still cause errors in older browsers as well if not transpiled to ES5. It would be nice if the main file for importing was transpiled to ES5 so that it could be imported as mapbox-gl-circle
; building and minifying would work well and unbuilt/unminified code could be assumed to work in older browsers.
When the current branch is master, the build identifier should be set based on version from the commit tag as per SemVer release spec: http://semver.org/#spec-item-2
E.g. "1.2.2"
after a Gitflow Workflow release-merge from release/1.2.2 branch
Depends upon:
When attempting to drag a center or radius handle, it consistently pans the map instead of triggering the intended handle. Once this has failed once, both center and radius handles work as intended.
Hi,
When adding the circle library to my mapbox app, it works fine on the desktop but I can't seem to interact with the circle at all on a mobile device.
Is there any way to get this working?
Thanks in advance
Should behave like google.maps.Circle
(obviously).
For a more advanced styling I'd need to keep track of a circle whose radius is being dragged.
Currently we only have 'radiuschanged' which is emitted once the drag has ended. So a 'radiuschanging' could come in handy.
To be consistent, a 'centerchanging' could also be added.
What do you think? would you accept a PR with this feature?
I am using react-map-gl
+ mapbox-gl-circle
. I displayed a circle but I cannot resize it and drag it.
But if I use mapbox-gl
+ mapbox-gl-circle
= all is good.
import React from "react";
import MapboxCircle from "mapbox-gl-circle";
import MapGL from "react-map-gl";
const MAPBOX_ACCESS_TOKEN =
"pk.eyJ1IjoiYWxlcGhyaSIsImEiOiJjamdwbHpycjIyZm45Mndud3AzamRibHpqIn0.ejAHwSGT6dcGxiDOrPCFLg";
export default function App() {
const [viewport, setViewport] = React.useState({
latitude: 6,
longitude: 22,
zoom: 12,
bearing: 0,
pitch: 0
});
const [mapRef, setMapRef] = React.useState(null);
const myCircle = new MapboxCircle({ lat: 6, lng: 22 }, 2200, {
editable: true,
minRadius: 120,
fillColor: "#29AB87"
});
if (mapRef !== null) {
myCircle.addTo(mapRef.getMap());
myCircle.on("centerchanged", function(circleObj) {
console.log("New center:", circleObj.getCenter());
});
myCircle.once("radiuschanged", function(circleObj) {
console.log("New radius (once!):", circleObj.getRadius());
});
myCircle.on("click", function(mapMouseEvent) {
console.log("Click:", mapMouseEvent.point);
});
myCircle.on("contextmenu", function(mapMouseEvent) {
console.log("Right-click:", mapMouseEvent.lngLat);
});
}
return (
<MapGL
ref={e => setMapRef(e)}
width="100%"
height="100vh"
mapStyle="mapbox://styles/mapbox/light-v9"
mapboxApiAccessToken={MAPBOX_ACCESS_TOKEN}
latitude={viewport.latitude}
longitude={viewport.longitude}
zoom={viewport.zoom}
bearing={viewport.bearing}
pitch={viewport.pitch}
onViewportChange={viewport => setViewport(viewport)}
/>
);
}
Codesandbox react-map-gl
example:
https://codesandbox.io/s/competent-feather-geo7c
Codesandbox mapbox-gl
example:
https://codesandbox.io/s/react-and-mapbox-gl-2tnnx
Must be importable as a drop-in replacement for Leaflet/Mapbox.js L.EditableCircle.
Hi I am using mapbox-gl-circle library to create circle on mapbox-gl map in my Angular application providing center of the circle and radius in metres.
Two simple questions:
Best regards.
When the current branch is of type release/, the build identifier should be set according to SemVer pre-release spec: http://semver.org/#spec-item-9
Format: "<upcoming_version>-rc.<build_number>"
E.g. "1.2.2-rc.3"
for build number 3 on release/1.2.2 branch
Depends upon:
Running Docker build:
docker build -t circle .
produces warnings on Step 4/8:
...
Step 4/8 : RUN npm install && mkdir -p example/ lib/
---> Running in 88bdb9b71fdb
npm WARN deprecated [email protected]: π Thanks for using Babel: we recommend using babel-preset-env now: please read babeljs.io/env to update!
npm WARN deprecated [email protected]: It is recommended to install Yarn using the native installation method for your environment. See https://yarnpkg.com/en/docs/install
npm WARN deprecated [email protected]: This package has been moved to @mapbox/mapbox-gl-supported
npm WARN deprecated [email protected]: This module is now under the @mapbox namespace: install @mapbox/geojson-area instead
npm WARN lifecycle [email protected]~prepare: cannot run in wd %s %s (wd=%s) [email protected] mkdir -p dist && browserify --standalone MapboxCircle -t [ babelify --presets [ es2015 ] ] lib/main.js | uglifyjs -c -m > dist/mapbox-gl-circle-${BUILD_VERSION:-dev}.min.js && cp -f dist/mapbox-gl-circle-${BUILD_VERSION:-dev}.min.js dist/mapbox-gl-circle.min.js /opt/mapbox-gl-circle
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
...
We should get these cleaned up to produce a clean Docker image.
Currently, when the circle is small enough, radius and center edit handlers will overlap.
Dragging one of those handlers will trigger both events _onCenterHandleMouseDown
and _onRadiusHandlesMouseDown
which provoke weird behaviours after mouseup/mouseout: the circle sticks to the cursor and you have to refresh the page to reset it:
I would expect only one of the events to be triggered: the one corresponding to the cursor style.
move
-> center handler mouse down eventns-resize
, ew-resize
-> radius handler mouse down eventPull request: #79
When the current branch is of Gitflow Workflow type feature/, bugfix/, or develop, the build identifier should be set to according to SemVer build metadata spec: http://semver.org/#spec-item-10
Depends upon:
There are a bunch of issues #100, #92, #91, #90, #89, #87, #83, #76, #72, #61, #60, #56, #49, and #25 they are left unanswered for years. Now @AbhishekD15 is wondering in #101, is it maintained or should it be marked as archived?
Someone files a bug or a feature request, and maintainers do not reply for multiple years.
I would expect maintainers to read their notifications and react in some way when filing a issue in their open source project.
N/A
N/A
ew-resize should only be used for handles on the sides, on top/bottom the vertical ns-resize arrow should be used.
When "illegally" edits are made, the application should be able to cancel the operation and restore the circle to its previous state.
Dragging and resizing doesnt work after zooming in to a certain level
It should allow to drag and resize at any zoom level
minRadius and maxRadius are hardcoded in v. 1.4.2; lines 161-162.
It would be better to expose these as constructor options, alongside fillColor, strokeOpacity and friends.
When the current branch is of type release/, the build should be automatically published to NPM after "Build Artifacts" stage steps have completed successfully, tagged as @next
.
Depends upon:
Its good if support dynamic options like fillcolor / editable will change dynamically.
#feature_request
I tried the resize and drag functionality of circle but these is not working as expected. Is there any possible to give support on IE11 browser ?
When dragging circle center:
Hey we built a map using mapbox-gl-circle. Works fine on local but when uglifies/minifies for production, the map that uses mapbox-gl-circle eats up CPU and browsers freezes
When calling .remove() on a circle instance, it should remove its map sources, layers and event listeners.
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.