@inlog/inlog-maps
Advanced tools
Comparing version 1.1.0-test to 1.2.0-test
@@ -776,3 +776,5 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
var polyline = this.getPolylines(type, condition); | ||
(_a = this.map) === null || _a === void 0 ? void 0 : _a.addPolylineEvent(polyline, event, eventFunction); | ||
if (polyline && polyline.length) { | ||
(_a = this.map) === null || _a === void 0 ? void 0 : _a.addPolylineEvent(polyline, event, eventFunction); | ||
} | ||
}; | ||
@@ -1116,3 +1118,3 @@ /** | ||
if (polylines && polylines.length) { | ||
return condition | ||
var resultFilter = condition | ||
? polylines.filter(function (polyline) { | ||
@@ -1122,5 +1124,5 @@ return condition(polyline.object); | ||
: polylines; | ||
return resultFilter.length > 0 ? resultFilter : polylines; | ||
} | ||
else | ||
return []; | ||
return []; | ||
}; | ||
@@ -1127,0 +1129,0 @@ Map.prototype.getOverlays = function (type, condition) { |
@@ -131,4 +131,4 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
this.leafletPopups = new LeafletPopups(map, leaflet_1); | ||
this.leafletMap = new LeafletMap(map, leaflet_1); | ||
this.leafletPolylines = new LeafletPolylines(map, leaflet_1, this.leafletPopups); | ||
this.leafletMap = new LeafletMap(map, leaflet_1, this.leafletPolylines); | ||
this.leafletOverlays = new LeafletOverlays(map, leaflet_1, this.leafletPolygons); | ||
@@ -334,2 +334,3 @@ this.leafletGeoJson = new LeafletGeoJson(map, leaflet_1); | ||
var _a; | ||
console.log("ADICIONANDO EVENTO POLYLINE", eventType); | ||
(_a = this.leafletPolylines) === null || _a === void 0 ? void 0 : _a.addPolylineEvent(polylines, eventType, eventFunction); | ||
@@ -336,0 +337,0 @@ }; |
@@ -5,3 +5,4 @@ import { MapEventType } from "../../dto/event-type"; | ||
private leaflet; | ||
constructor(map: any, leaflet: any); | ||
private leafletPolyline?; | ||
constructor(map: any, leaflet: any, leafletPolyline?: any); | ||
resizeMap(): void; | ||
@@ -8,0 +9,0 @@ addEventMap(eventType: MapEventType, eventFunction: any): void; |
@@ -40,7 +40,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
var LeafletMap = /** @class */ (function () { | ||
function LeafletMap(map, leaflet) { | ||
function LeafletMap(map, leaflet, leafletPolyline) { | ||
this.map = {}; | ||
this.leaflet = {}; | ||
this.leafletPolyline = {}; | ||
this.map = map; | ||
this.leaflet = leaflet; | ||
this.leafletPolyline = leafletPolyline; | ||
} | ||
@@ -55,2 +57,3 @@ LeafletMap.prototype.resizeMap = function () { | ||
self.map.on("click", function (event) { | ||
var _a; | ||
var param = new EventReturn([ | ||
@@ -60,3 +63,8 @@ event.latlng.lat, | ||
]); | ||
eventFunction(param); | ||
var isEdit = (_a = self.leafletPolyline) === null || _a === void 0 ? void 0 : _a.getEditModeBlockingMapClick(); | ||
console.log("IS EDIT", isEdit); | ||
if (!isEdit) { | ||
console.log("EVENT CLICK"); | ||
eventFunction(param); | ||
} | ||
}); | ||
@@ -63,0 +71,0 @@ break; |
@@ -24,2 +24,4 @@ import { PolylineEventType } from "../../dto/event-type"; | ||
isPolylineOnMap(polyline: any): boolean; | ||
getEditModeBlockingMapClick(): boolean; | ||
setEditModeBlockingMapClick(newState: boolean): void; | ||
addPolylinePath(polylines: any, position: number[]): void; | ||
@@ -26,0 +28,0 @@ getPolylinePath(polyline: any): number[][]; |
@@ -23,2 +23,3 @@ // import { Polyline } from "leaflet"; | ||
LeafletPolylines.prototype.drawPolyline = function (options, eventClick) { | ||
var _this = this; | ||
var self = this; | ||
@@ -55,15 +56,19 @@ var newOptions = { | ||
self.leaflet.DomEvent.stopPropagation(event); | ||
var param = new EventReturn([ | ||
event.latlng.lat, | ||
event.latlng.lng, | ||
]); | ||
eventClick(param, event.target.object); | ||
if (!_this.getEditModeBlockingMapClick()) { | ||
var param = new EventReturn([ | ||
event.latlng.lat, | ||
event.latlng.lng, | ||
]); | ||
eventClick(param, event.target.object); | ||
} | ||
}); | ||
polyline.on("editable:vertex:rawclick", function (event) { | ||
event.cancel(); | ||
var param = new EventReturn([ | ||
event.latlng.lat, | ||
event.latlng.lng, | ||
]); | ||
eventClick(param, event.target.object); | ||
if (!_this.getEditModeBlockingMapClick()) { | ||
var param = new EventReturn([ | ||
event.latlng.lat, | ||
event.latlng.lng, | ||
]); | ||
eventClick(param, event.target.object); | ||
} | ||
}); | ||
@@ -245,6 +250,16 @@ } | ||
}; | ||
LeafletPolylines.prototype.getEditModeBlockingMapClick = function () { | ||
return this.editModeBlockingMapClick; | ||
}; | ||
LeafletPolylines.prototype.setEditModeBlockingMapClick = function (newState) { | ||
this.editModeBlockingMapClick = newState; | ||
}; | ||
// TODO: Fazer uma função tipo getEditModelBlockingMap | ||
// Fazer o leaflet-map ter acesso a essa função. | ||
// Antes de dar o click do evento, perguntar se pode. | ||
// Se puder deixar ou não executa o click. | ||
LeafletPolylines.prototype.addPolylinePath = function (polylines, position) { | ||
var _this = this; | ||
// TODO: Só adiciona linha se não estiver editando no mesmo momento. | ||
if (!this.editModeBlockingMapClick) { | ||
if (!this.getEditModeBlockingMapClick) { | ||
polylines.forEach(function (polyline) { | ||
@@ -628,4 +643,5 @@ var path = polyline.getLatLngs(); | ||
polyline.on("editable:vertex:dragstart", function (eventStart) { | ||
console.log("DRAG START"); | ||
_this.setEditModeBlockingMapClick(true); | ||
// TODO: Se estiver editando um trecho na polyline, não libera para novos trechos. (duplo clique) | ||
_this.editModeBlockingMapClick = true; | ||
var lastPosition = new EventReturn([ | ||
@@ -648,5 +664,7 @@ eventStart.vertex.latlng.lat, | ||
polyline.off("editable:vertex:dragend"); | ||
console.log("DRAG END"); | ||
setTimeout(function () { | ||
_this.editModeBlockingMapClick = false; | ||
}, 300); | ||
console.log("CLICK ABLE"); | ||
_this.setEditModeBlockingMapClick(false); | ||
}, 1000); | ||
}); | ||
@@ -653,0 +671,0 @@ }); |
@@ -776,3 +776,5 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
var polyline = this.getPolylines(type, condition); | ||
(_a = this.map) === null || _a === void 0 ? void 0 : _a.addPolylineEvent(polyline, event, eventFunction); | ||
if (polyline && polyline.length) { | ||
(_a = this.map) === null || _a === void 0 ? void 0 : _a.addPolylineEvent(polyline, event, eventFunction); | ||
} | ||
}; | ||
@@ -1116,3 +1118,3 @@ /** | ||
if (polylines && polylines.length) { | ||
return condition | ||
var resultFilter = condition | ||
? polylines.filter(function (polyline) { | ||
@@ -1122,5 +1124,5 @@ return condition(polyline.object); | ||
: polylines; | ||
return resultFilter.length > 0 ? resultFilter : polylines; | ||
} | ||
else | ||
return []; | ||
return []; | ||
}; | ||
@@ -1127,0 +1129,0 @@ Map.prototype.getOverlays = function (type, condition) { |
@@ -131,4 +131,4 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
this.leafletPopups = new LeafletPopups(map, leaflet_1); | ||
this.leafletMap = new LeafletMap(map, leaflet_1); | ||
this.leafletPolylines = new LeafletPolylines(map, leaflet_1, this.leafletPopups); | ||
this.leafletMap = new LeafletMap(map, leaflet_1, this.leafletPolylines); | ||
this.leafletOverlays = new LeafletOverlays(map, leaflet_1, this.leafletPolygons); | ||
@@ -334,2 +334,3 @@ this.leafletGeoJson = new LeafletGeoJson(map, leaflet_1); | ||
var _a; | ||
console.log("ADICIONANDO EVENTO POLYLINE", eventType); | ||
(_a = this.leafletPolylines) === null || _a === void 0 ? void 0 : _a.addPolylineEvent(polylines, eventType, eventFunction); | ||
@@ -336,0 +337,0 @@ }; |
@@ -5,3 +5,4 @@ import { MapEventType } from "../../dto/event-type"; | ||
private leaflet; | ||
constructor(map: any, leaflet: any); | ||
private leafletPolyline?; | ||
constructor(map: any, leaflet: any, leafletPolyline?: any); | ||
resizeMap(): void; | ||
@@ -8,0 +9,0 @@ addEventMap(eventType: MapEventType, eventFunction: any): void; |
@@ -40,7 +40,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
var LeafletMap = /** @class */ (function () { | ||
function LeafletMap(map, leaflet) { | ||
function LeafletMap(map, leaflet, leafletPolyline) { | ||
this.map = {}; | ||
this.leaflet = {}; | ||
this.leafletPolyline = {}; | ||
this.map = map; | ||
this.leaflet = leaflet; | ||
this.leafletPolyline = leafletPolyline; | ||
} | ||
@@ -55,2 +57,3 @@ LeafletMap.prototype.resizeMap = function () { | ||
self.map.on("click", function (event) { | ||
var _a; | ||
var param = new EventReturn([ | ||
@@ -60,3 +63,8 @@ event.latlng.lat, | ||
]); | ||
eventFunction(param); | ||
var isEdit = (_a = self.leafletPolyline) === null || _a === void 0 ? void 0 : _a.getEditModeBlockingMapClick(); | ||
console.log("IS EDIT", isEdit); | ||
if (!isEdit) { | ||
console.log("EVENT CLICK"); | ||
eventFunction(param); | ||
} | ||
}); | ||
@@ -63,0 +71,0 @@ break; |
@@ -24,2 +24,4 @@ import { PolylineEventType } from "../../dto/event-type"; | ||
isPolylineOnMap(polyline: any): boolean; | ||
getEditModeBlockingMapClick(): boolean; | ||
setEditModeBlockingMapClick(newState: boolean): void; | ||
addPolylinePath(polylines: any, position: number[]): void; | ||
@@ -26,0 +28,0 @@ getPolylinePath(polyline: any): number[][]; |
@@ -23,2 +23,3 @@ // import { Polyline } from "leaflet"; | ||
LeafletPolylines.prototype.drawPolyline = function (options, eventClick) { | ||
var _this = this; | ||
var self = this; | ||
@@ -55,15 +56,19 @@ var newOptions = { | ||
self.leaflet.DomEvent.stopPropagation(event); | ||
var param = new EventReturn([ | ||
event.latlng.lat, | ||
event.latlng.lng, | ||
]); | ||
eventClick(param, event.target.object); | ||
if (!_this.getEditModeBlockingMapClick()) { | ||
var param = new EventReturn([ | ||
event.latlng.lat, | ||
event.latlng.lng, | ||
]); | ||
eventClick(param, event.target.object); | ||
} | ||
}); | ||
polyline.on("editable:vertex:rawclick", function (event) { | ||
event.cancel(); | ||
var param = new EventReturn([ | ||
event.latlng.lat, | ||
event.latlng.lng, | ||
]); | ||
eventClick(param, event.target.object); | ||
if (!_this.getEditModeBlockingMapClick()) { | ||
var param = new EventReturn([ | ||
event.latlng.lat, | ||
event.latlng.lng, | ||
]); | ||
eventClick(param, event.target.object); | ||
} | ||
}); | ||
@@ -245,6 +250,16 @@ } | ||
}; | ||
LeafletPolylines.prototype.getEditModeBlockingMapClick = function () { | ||
return this.editModeBlockingMapClick; | ||
}; | ||
LeafletPolylines.prototype.setEditModeBlockingMapClick = function (newState) { | ||
this.editModeBlockingMapClick = newState; | ||
}; | ||
// TODO: Fazer uma função tipo getEditModelBlockingMap | ||
// Fazer o leaflet-map ter acesso a essa função. | ||
// Antes de dar o click do evento, perguntar se pode. | ||
// Se puder deixar ou não executa o click. | ||
LeafletPolylines.prototype.addPolylinePath = function (polylines, position) { | ||
var _this = this; | ||
// TODO: Só adiciona linha se não estiver editando no mesmo momento. | ||
if (!this.editModeBlockingMapClick) { | ||
if (!this.getEditModeBlockingMapClick) { | ||
polylines.forEach(function (polyline) { | ||
@@ -628,4 +643,5 @@ var path = polyline.getLatLngs(); | ||
polyline.on("editable:vertex:dragstart", function (eventStart) { | ||
console.log("DRAG START"); | ||
_this.setEditModeBlockingMapClick(true); | ||
// TODO: Se estiver editando um trecho na polyline, não libera para novos trechos. (duplo clique) | ||
_this.editModeBlockingMapClick = true; | ||
var lastPosition = new EventReturn([ | ||
@@ -648,5 +664,7 @@ eventStart.vertex.latlng.lat, | ||
polyline.off("editable:vertex:dragend"); | ||
console.log("DRAG END"); | ||
setTimeout(function () { | ||
_this.editModeBlockingMapClick = false; | ||
}, 300); | ||
console.log("CLICK ABLE"); | ||
_this.setEditModeBlockingMapClick(false); | ||
}, 1000); | ||
}); | ||
@@ -653,0 +671,0 @@ }); |
{ | ||
"name": "@inlog/inlog-maps", | ||
"version": "1.1.0-test", | ||
"version": "1.2.0-test", | ||
"description": "A library for using generic layer maps ", | ||
@@ -12,3 +12,5 @@ "main": "index.js", | ||
"start": "webpack-dev-server --mode development", | ||
"test": "mocha --reporter spec" | ||
"publish": "npm publish --access public", | ||
"test": "mocha --reporter spec", | ||
"demo": "nodemon" | ||
}, | ||
@@ -15,0 +17,0 @@ "repository": { |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
4053051
267
17794
0