Subversion Repositories eFlore/Applications.cel

Rev

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

Rev 3848 Rev 3849
Line 153... Line 153...
153
 
153
 
154
Geoloc.prototype.initEvts = function() {
154
Geoloc.prototype.initEvts = function() {
155
    this.initMap();
155
    this.initMap();
156
    this.handleCoordinates();
156
    this.handleCoordinates();
157
    this.onCoordinates();
-
 
158
    if('point' === this.geometryFilter) {
157
    this.onCoordinates();
159
        this.initSearchLocality();
-
 
160
    }
158
    this.initSearchLocality();
Line 161... Line 159...
161
};
159
};
162
 
160
 
Line 282... Line 280...
282
Geoloc.prototype.handleMarkerEvents = function() {
280
Geoloc.prototype.handleMarkerEvents = function() {
283
    if(this.map) {
281
    if(this.map) {
284
        const lthis = this;
282
        const lthis = this;
285
        // move marker on click
283
        // move marker on click
286
        $(this.map).off('click').on('click', function(evt) {
284
        $(this.map).off('click').on('click', function(evt) {
287
            lthis.handleNewLocation(evt.latlng);
285
            lthis.handleNewLocation(evt.originalEvent.latlng);
288
        });
286
        });
289
        // move marker on drag
287
        // move marker on drag
290
        $(this.map.marker).off('dragend').on('dragend', function() {
288
        $(this.map.marker).off('dragend').on('dragend', function() {
291
            lthis.handleNewLocation(lthis.map.marker.getLatLng());
289
            lthis.handleNewLocation(lthis.map.marker.getLatLng());
292
        });
290
        });
Line 320... Line 318...
320
 */
318
 */
321
Geoloc.prototype.handleNewLocation = function (coordinates, polyline = []) {
319
Geoloc.prototype.handleNewLocation = function (coordinates, polyline = []) {
322
    coordinates = this.formatCoordinates(coordinates);
320
    coordinates = this.formatCoordinates(coordinates);
Line 323... Line 321...
323
 
321
 
-
 
322
    if(!!coordinates && !!coordinates.lat && coordinates.lng) {
324
    if(!!coordinates && !!coordinates.lat && coordinates.lng) {
323
        this.zoom = 20;
-
 
324
        this.setMapCoordinates(coordinates);
325
        this.setMapCoordinates(coordinates);
325
 
326
        if('point' === this.geometryFilter) {
326
        if('point' === this.geometryFilter) {
327
            this.createDraggableMarker();
327
            this.createDraggableMarker();
328
            this.handleMarkerEvents();
328
            this.handleMarkerEvents();
-
 
329
        }
-
 
330
 
-
 
331
        if (
-
 
332
            ('rue' === this.geometryFilter && 0 < polyline.length) ||
-
 
333
            ('point' === this.geometryFilter && 0 === polyline.length)
329
        }
334
        ) {
-
 
335
            this.getLocationInfo(coordinates, polyline);
330
        this.getLocationInfo(coordinates, polyline);
336
        }
331
    }
337
    }
Line 332... Line 338...
332
};
338
};
333
 
339
 
Line 351... Line 357...
351
};
357
};
Line 352... Line 358...
352
 
358
 
353
Geoloc.prototype.setMapCoordinates = function (coordinates) {
359
Geoloc.prototype.setMapCoordinates = function (coordinates) {
354
    this.coordinates = coordinates;
360
    this.coordinates = coordinates;
355
    // updates map
361
    // updates map
356
    this.map.setView(coordinates);
362
    this.map.setView(coordinates,this.zoom);
Line 357... Line 363...
357
};
363
};
358
 
364
 
359
Geoloc.prototype.createDraggableMarker = function() {
365
Geoloc.prototype.createDraggableMarker = function() {
Line 502... Line 508...
502
        const coordinates = {
508
        const coordinates = {
503
            'lat' : localityData.lat,
509
            'lat' : localityData.lat,
504
            'lng' : localityData.lon
510
            'lng' : localityData.lon
505
        };
511
        };
Line -... Line 512...
-
 
512
 
506
 
513
        if ('point' === this.geometryFilter) {
-
 
514
            this.map.removeControl(this.drawControl);
-
 
515
        }
507
        this.map.removeControl(this.drawControl);
516
        this.zoom = 18;
508
        this.handleNewLocation(coordinates);
517
        this.handleNewLocation(coordinates);
509
    }
518
    }
Line 510... Line 519...
510
};
519
};