Subversion Repositories eFlore/Applications.cel

Rev

Rev 3847 | Rev 3849 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 3847 Rev 3848
Line 320... Line 320...
320
 */
320
 */
321
Geoloc.prototype.handleNewLocation = function (coordinates, polyline = []) {
321
Geoloc.prototype.handleNewLocation = function (coordinates, polyline = []) {
322
    coordinates = this.formatCoordinates(coordinates);
322
    coordinates = this.formatCoordinates(coordinates);
Line 323... Line 323...
323
 
323
 
324
    if(!!coordinates && !!coordinates.lat && coordinates.lng) {
324
    if(!!coordinates && !!coordinates.lat && coordinates.lng) {
-
 
325
        this.setMapCoordinates(coordinates);
-
 
326
        if('point' === this.geometryFilter) {
-
 
327
            this.createDraggableMarker();
-
 
328
            this.handleMarkerEvents();
325
        this.setMapPosition(coordinates);
329
        }
326
        this.getLocationInfo(coordinates, polyline);
330
        this.getLocationInfo(coordinates, polyline);
327
    }
331
    }
Line 328... Line 332...
328
};
332
};
Line 344... Line 348...
344
    latLngs.forEach(coordinates => polyline.push(Object.values(coordinates)));
348
    latLngs.forEach(coordinates => polyline.push(Object.values(coordinates)));
Line 345... Line 349...
345
 
349
 
346
    return polyline;
350
    return polyline;
Line 347... Line 351...
347
};
351
};
348
 
-
 
349
Geoloc.prototype.setMapPosition = function (coordinates) {
-
 
350
    const latLng = new L.LatLng(coordinates.lat, coordinates.lng);
-
 
351
 
352
 
352
 
-
 
353
    this.coordinates = coordinates;
-
 
354
    if('point' === this.geometryFilter) {
-
 
355
        this.createDraggableMarker(latLng);
-
 
356
        this.handleMarkerEvents();
353
Geoloc.prototype.setMapCoordinates = function (coordinates) {
357
    }
354
    this.coordinates = coordinates;
358
    // updates map
355
    // updates map
Line 359... Line 356...
359
    this.map.setView(latLng);
356
    this.map.setView(coordinates);
360
};
-
 
361
 
-
 
362
Geoloc.prototype.createDraggableMarker = function(latLng) {
-
 
363
    if (undefined === latLng) {
-
 
364
        latLng = new L.LatLng(this.coordinates.lat, this.coordinates.lng);
357
};
365
    }
358
 
366
 
359
Geoloc.prototype.createDraggableMarker = function() {
367
    if (undefined === this.map.marker) {
360
    if (undefined === this.map.marker) {
368
        // after many attempts, did not manage
361
        // after many attempts, did not manage
Line 380... Line 373...
380
        if(this.drawControl) {
373
        if(this.drawControl) {
381
            this.map.removeControl(this.drawControl);
374
            this.map.removeControl(this.drawControl);
382
        }
375
        }
383
    }
376
    }
Line 384... Line 377...
384
 
377
 
385
    this.map.marker.setLatLng(latLng, {draggable: 'true'});
378
    this.map.marker.setLatLng(this.coordinates, {draggable: 'true'});
Line 386... Line 379...
386
};
379
};
387
 
380
 
388
Geoloc.prototype.getLocationInfo = function(coordinates, polyline) {
381
Geoloc.prototype.getLocationInfo = function(coordinates, polyline) {