new-poly: new poly, continue forward

This commit is contained in:
muerwre 2018-12-18 16:57:33 +07:00
parent 3093bd24da
commit 2f9952e8fa
7 changed files with 723 additions and 5 deletions

View file

@ -1,4 +1,5 @@
import { Map } from '$modules/Map';
import { NewPoly } from '$modules/NewPoly';
import { Poly } from '$modules/Poly';
import { MODES } from '$constants/modes';
import { Stickers } from '$modules/Stickers';
@ -40,6 +41,11 @@ export class Editor {
this.poly = new Poly({
map, routerMoveStart, lockMapClicks, setTotalDist: this.setDistance, triggerOnChange, editor: this,
});
this.newPoly = new NewPoly({
map, editor: this,
});
this.stickers = new Stickers({ map, lockMapClicks, triggerOnChange });
this.router = new Router({
map, lockMapClicks, setRouterPoints: this.setRouterPoints, changeMode, pushPolyPoints

45
src/modules/NewPoly.js Normal file
View file

@ -0,0 +1,45 @@
import L from 'leaflet';
import 'leaflet-geometryutil';
import '../utils/EditablePolyline';
import { simplify } from '$utils/simplify';
import { findDistance, middleCoord } from '$utils/geom';
import { CLIENT } from '$config/frontend';
import { MODES } from '$constants/modes';
const polyStyle = {
color: 'url(#activePathGradient)',
weight: '6',
markerMid: 'url(#arrow)'
};
// const polyStyle = { color: '#ff3344', weight: '5' };
export class NewPoly {
constructor({
map, routerMoveStart, lockMapClicks, setTotalDist, triggerOnChange, editor,
}) {
// this.poly = L.polyline([], polyStyle);
const coordinates = [
[54.985987, 82.921543],
[55.03845, 82.97699],
[55.0345, 82.67699],
[55.0145, 82.67699],
];
this.poly = L.Polyline.PolylineEditor(coordinates, { ...polyStyle, maxMarkers: 300 }).addTo(map);
this.poly.addTo(map);
map.fitBounds(this.poly.getBounds());
//
// this.latlngs = [];
// this.poly.addTo(map);
// this.editor = editor;
//
// this.map = map;
//
// this.routerMoveStart = routerMoveStart;
// this.setTotalDist = setTotalDist;
// this.triggerOnChange = triggerOnChange;
// this.lockMapClicks = lockMapClicks;
// this.bindEvents();
//
// this.arrows = new L.LayerGroup().addTo(map);
}
}