mirror of
https://github.com/muerwre/orchidmap-front.git
synced 2025-04-25 19:16:41 +07:00
fixed drawing polyline
This commit is contained in:
parent
2b5b5ccf6c
commit
807bea9ec2
3 changed files with 15 additions and 56 deletions
|
@ -2,9 +2,11 @@
|
||||||
|
|
||||||
## BUGS
|
## BUGS
|
||||||
|
|
||||||
|
todo fix arrows (can't reproduce now :-( )
|
||||||
todo clear routing on editing cancellation
|
todo clear routing on editing cancellation
|
||||||
todo cancelling editing someone's else map return back to it's original address /razminochnyj/
|
todo cancelling editing someone's else map return back to it's original address /razminochnyj/
|
||||||
todo selecting logo on crop
|
todo selecting logo on crop
|
||||||
|
todo delete sticker icon
|
||||||
|
|
||||||
## FEATURES
|
## FEATURES
|
||||||
|
|
||||||
|
|
|
@ -57,7 +57,7 @@ export class NewPoly {
|
||||||
|
|
||||||
if (!latlngs || latlngs.length <= 1) return;
|
if (!latlngs || latlngs.length <= 1) return;
|
||||||
|
|
||||||
latlngs.map((latlng, i) => {
|
latlngs.forEach((latlng, i) => {
|
||||||
if (i === 0) return;
|
if (i === 0) return;
|
||||||
|
|
||||||
const mid = middleCoord(latlngs[i], latlngs[i - 1]);
|
const mid = middleCoord(latlngs[i], latlngs[i - 1]);
|
||||||
|
@ -70,14 +70,14 @@ export class NewPoly {
|
||||||
latlngs[i - 1],
|
latlngs[i - 1],
|
||||||
[mid.lat, mid.lng]
|
[mid.lat, mid.lng]
|
||||||
],
|
],
|
||||||
{ color: 'none', weight: CLIENT.STROKE_WIDTH }
|
{ color: 'blue', weight: CLIENT.STROKE_WIDTH }
|
||||||
).addTo(this.arrows);
|
).addTo(this.arrows);
|
||||||
|
|
||||||
slide._path.setAttribute('marker-end', 'url(#long-arrow)');
|
slide._path.setAttribute('marker-end', 'url(#long-arrow)');
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
updateMarks = (e, callee) => {
|
updateMarks = () => {
|
||||||
// return;
|
// return;
|
||||||
const coords = this.poly.toGeoJSON().geometry.coordinates;
|
const coords = this.poly.toGeoJSON().geometry.coordinates;
|
||||||
|
|
||||||
|
@ -103,52 +103,8 @@ export class NewPoly {
|
||||||
if (mode === MODES.NONE) this.editor.setMode(MODES.POLY);
|
if (mode === MODES.NONE) this.editor.setMode(MODES.POLY);
|
||||||
};
|
};
|
||||||
|
|
||||||
bindEvents = () => {
|
|
||||||
// Если на карте что-то меняется, пересчитать километражи
|
|
||||||
// this.map.editTools.addEventListener('editable:drawing:mouseup', this.updateMarks);
|
|
||||||
// this.map.editTools.addEventListener('editable:vertex:dragend', this.updateMarks);
|
|
||||||
// this.map.editTools.addEventListener('editable:vertex:mouseup', this.updateMarks);
|
|
||||||
// this.map.editTools.addEventListener('editable:vertex:deleted', this.updateMarks);
|
|
||||||
// this.map.editTools.addEventListener('editable:vertex:new', this.updateMarks);
|
|
||||||
// this.map.editTools.addEventListener('editable:vertex:click', this.preventMissClicks);
|
|
||||||
|
|
||||||
// this.map.editTools.addEventListener('editable:vertex:dragstart', this.lockMap);
|
|
||||||
// this.map.editTools.addEventListener('editable:vertex:dragstart', this.clearArrows);
|
|
||||||
|
|
||||||
// После удаления точки - продолжить рисование
|
|
||||||
// this.map.editTools.addEventListener('editable:vertex:deleted', this.continueForward);
|
|
||||||
//
|
|
||||||
// map.editTools.addEventListener('editable:vertex:dragend', e => writeReduxData({ e, updatePolyCoords }));
|
|
||||||
// map.editTools.addEventListener('editable:vertex:new', e => writeReduxData({ e, updatePolyCoords }));
|
|
||||||
// map.editTools.addEventListener('editable:vertex:deleted', e => writeReduxData({ e, updatePolyCoords }));
|
|
||||||
|
|
||||||
// Продолжить рисование после удаления точки
|
|
||||||
// map.editTools.addEventListener('editable:vertex:deleted', e => {
|
|
||||||
// poly.editor.continueForward();
|
|
||||||
// updateMarks();
|
|
||||||
// });
|
|
||||||
|
|
||||||
// Добавлять точек в полилинию по щелчку
|
|
||||||
// map.editTools.addEventListener('editable:drawing:click', e => insertVertex({ e, updatePolyCoords }));
|
|
||||||
// map.editTools.addEventListener('editable:drawing:clicked', () => updateMarks({ updatePolyCoords }));
|
|
||||||
|
|
||||||
// Это для точек. При перетаскивании конца указателя тащим точку
|
|
||||||
// map.editTools.addEventListener('editable:vertex:drag', on_vertex_drag);
|
|
||||||
|
|
||||||
// при перетаскивании ручек убирать все отметки километров
|
|
||||||
// map.editTools.addEventListener('editable:vertex:dragstart', clearKmMarks);
|
|
||||||
};
|
|
||||||
|
|
||||||
continue = () => {
|
continue = () => {
|
||||||
this.poly.editor.continueForward();
|
this.poly.editor.continueForward();
|
||||||
// if (this.latlngs && this.latlngs.length) {
|
|
||||||
// // this.poly.enableEdit().continueForward();
|
|
||||||
// // this.poly.editor.reset();
|
|
||||||
// this.poly.continueForward();
|
|
||||||
// } else {
|
|
||||||
// // this.poly = this.map.editTools.startPolyline();
|
|
||||||
// // this.poly.setStyle(polyStyle);
|
|
||||||
// }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
stop = () => {
|
stop = () => {
|
||||||
|
@ -166,8 +122,6 @@ export class NewPoly {
|
||||||
setPoints = latlngs => {
|
setPoints = latlngs => {
|
||||||
if (!latlngs || latlngs.length <= 1) return;
|
if (!latlngs || latlngs.length <= 1) return;
|
||||||
this.poly.setPoints(latlngs);
|
this.poly.setPoints(latlngs);
|
||||||
// this.poly._reloadPolyline();
|
|
||||||
// this.updateMarks();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
pushPoints = latlngs => {
|
pushPoints = latlngs => {
|
||||||
|
@ -186,9 +140,8 @@ export class NewPoly {
|
||||||
|
|
||||||
clearAll = () => {
|
clearAll = () => {
|
||||||
this.poly.setLatLngs([]);
|
this.poly.setLatLngs([]);
|
||||||
// this.poly.disableEdit();
|
this.poly.editor.reset();
|
||||||
|
this.updateMarks();
|
||||||
// this.updateMarks();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
clearArrows = () => this.arrows.clearLayers();
|
clearArrows = () => this.arrows.clearLayers();
|
||||||
|
@ -199,7 +152,6 @@ export class NewPoly {
|
||||||
return (
|
return (
|
||||||
this.poly && this.poly.getLatLngs().length
|
this.poly && this.poly.getLatLngs().length
|
||||||
&& this.poly.getLatLngs().map(el => ({ ...el }))) || [];
|
&& this.poly.getLatLngs().map(el => ({ ...el }))) || [];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
get isEmpty() {
|
get isEmpty() {
|
||||||
|
|
|
@ -453,14 +453,18 @@ L.Polyline.polylineEditor = L.Polyline.extend({
|
||||||
|
|
||||||
// User-defined custom event listeners:
|
// User-defined custom event listeners:
|
||||||
if (that._options.customPointListeners) {
|
if (that._options.customPointListeners) {
|
||||||
for (let eventName in that._options.customPointListeners) { marker.on(eventName, that._options.customPointListeners[eventName]); }
|
for (let eventName in that._options.customPointListeners) {
|
||||||
|
marker.on(eventName, that._options.customPointListeners[eventName]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (that._options.customNewPointListeners) {
|
if (that._options.customNewPointListeners) {
|
||||||
for (let eventName in that._options.customNewPointListeners) { newPointMarker.on(eventName, that._options.customNewPointListeners[eventName]); }
|
for (let eventName in that._options.customNewPointListeners) {
|
||||||
|
newPointMarker.on(eventName, that._options.customNewPointListeners[eventName]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// exit if its first marker
|
// exit if its first marker
|
||||||
if (!this._markers || this._markers.length <= 0) {
|
if (!this._markers || this._markers.length === 0 || points.length === 0) {
|
||||||
this._markers.push(marker);
|
this._markers.push(marker);
|
||||||
return marker;
|
return marker;
|
||||||
}
|
}
|
||||||
|
@ -556,6 +560,7 @@ L.Polyline.polylineEditor = L.Polyline.extend({
|
||||||
|
|
||||||
this._addFirstPoint = event => {
|
this._addFirstPoint = event => {
|
||||||
this._addMarkers(0, event.latlng, true);
|
this._addMarkers(0, event.latlng, true);
|
||||||
|
this._map.setEditablePolylinesEnabled(true);
|
||||||
this._reloadPolyline();
|
this._reloadPolyline();
|
||||||
|
|
||||||
this._map.off('click', this._addFirstPoint);
|
this._map.off('click', this._addFirstPoint);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue