Subversion Repositories eFlore/Applications.cel

Compare Revisions

Regard whitespace Rev 3869 → Rev 3868

/branches/v3.01-serpe/widget/modules/saisie/squelettes/js/Utils.js
180,6 → 180,7
const thisFieldKey = $( this ).data( 'key' ),
fileMimeType = $( this ).data( 'mime-type' ),
label = 'Aide pour : ' + $( this ).data( 'name' );
 
let content = '';
 
if( fileMimeType.match( 'image' ) ) {
/branches/v3.01-serpe/widget/modules/saisie/squelettes/js/tb-geoloc/js/Geoloc.js
202,6 → 202,7
this.onCoordinates();
};
 
 
Geoloc.prototype.reSetDrawControl = function() {
this.map.removeLayer(this.layer);
this.map.removeControl(this.drawControl);
359,7 → 360,7
Geoloc.prototype.formatPolyline = function (latLngs) {
const polyline = [];
 
latLngs.forEach(coordinates => polyline.push(Object.values(coordinates).reverse()));
latLngs.forEach(coordinates => polyline.push(Object.values(coordinates)));
 
return polyline;
};
408,9 → 409,7
url: url,
data: params,
success: function(locationData) {
locationData.centroid = lthis.formatPointTypeCoordinates(coordinates);
locationData.geojson = 'rue' === lthis.geometryFilter ? {type: 'LineString', coordinates: polyline} : locationData.centroid;
lthis.loadGeolocation(coordinates,locationData);
lthis.loadGeolocation(coordinates,locationData,polyline);
},
error: (err) => {
console.warn(err);
419,11 → 418,7
});
};
 
Geoloc.prototype.formatPointTypeCoordinates = function(coordinates) {
return {type : 'Point', coordinates: Object.values(coordinates).reverse()};
};
 
Geoloc.prototype.loadGeolocation = function(coordinates,locationData) {
Geoloc.prototype.loadGeolocation = function(coordinates,locationData,polyline) {
const lthis = this,
query = {
'lat': coordinates.lat,
436,7 → 431,7
data: query,
success: function (geoLocationData) {
lthis.triggerLocationEvent(
lthis.formatLocationEventObject(locationData,geoLocationData)
lthis.formatLocationEventObject(coordinates,geoLocationData,locationData,polyline)
);
lthis.geolocLabel.classList.remove('loading');
},
448,15 → 443,17
};
 
Geoloc.prototype.triggerLocationEvent = function(locationDataObject) {
const locationEvent = new CustomEvent('location', {detail: locationDataObject});
const location = new CustomEvent('location', {detail: locationDataObject});
 
this.mapEl.dispatchEvent(locationEvent);
this.mapEl.dispatchEvent(location);
};
 
Geoloc.prototype.formatLocationEventObject = function(locationData,geoLocationData) {
Geoloc.prototype.formatLocationEventObject = function(coordinates,geoLocationData,locationData,polyline) {
const detail = {
centroid: locationData.centroid,
geometry: locationData.geojson,
centroid: {
type: 'Point',
coordinates: Object.values(coordinates)
},
elevation: geoLocationData.altitude,
inseeData: {
code: geoLocationData.code_zone,
474,9 → 471,18
osmPlaceId: locationData.place_id
};
 
return detail;
if (0 < polyline.length) {
detail.geometry = {
type: 'LineString',
coordinates: polyline
};
} else {
detail.geometry = detail.centroid;
}
 
return detail;
}
 
Geoloc.prototype.handleCoordinates = function() {
if (!!this.latitudeEl.value && !!this.longitudeEl.value) {
this.handleNewLocation({
508,28 → 514,17
const locality = this.getLocalityFromData(localityData);
 
if(!!locality) {
const coordinates = this.formatCoordinates({
const coordinates = {
'lat' : localityData.lat,
'lng' : localityData.lon
});
};
 
if(!!coordinates && !!coordinates.lat && !!coordinates.lng) {
this.zoom = 20;
this.setMapCoordinates(coordinates);
 
if('point' === this.geometryFilter) {
this.map.removeControl(this.drawControl);
this.createDraggableMarker();
this.handleMarkerEvents();
}
 
localityData.centroid = this.formatPointTypeCoordinates(coordinates);
if('rue' !== this.geometryFilter && 'Polygon' === localityData.geojson.type ) {
localityData.geojson = localityData.centroid;
this.zoom = 18;
this.handleNewLocation(coordinates);
}
this.loadGeolocation(coordinates,localityData);
}
}
};
 
Geoloc.prototype.getLocalityFromData = function(localityData) {
/branches/v3.01-serpe/widget/modules/saisie/squelettes/js/tb-geoloc/js/modules/Locality.js
69,12 → 69,7
TbPlaces.prototype.launchSearch = function () {
if (!!this.places.val()) {
const url = NOMINATIM_OSM_URL+'search',
params = {
'q': this.places.val(),
'format': 'json',
'polygon_geojson': 1,
'zoom': 17
};
params = {'q': this.places.val()};
 
this.placeLabel.addClass('loading');
$.ajax({
122,21 → 117,15
}
}
});
if(0 < acceptedSuggestions.length) {
this.placesResultsContainer.removeClass('hidden');
} else {
this.resetPlacesSearch();
}
};
 
TbPlaces.prototype.validateSuggestionData = function(suggestion) {
const validGeometry = undefined !== suggestion.lat && undefined !== suggestion.lon,
typeLocalisation = this.places.data('typeLocalisation') || '',
validGeometryType = 'rue' === typeLocalisation ? 'LineString' === suggestion?.geojson.type : true,
validAddressData = undefined !== suggestion.address,
validDisplayName = undefined !== suggestion['display_name'];
 
return (validGeometry && validGeometryType && validAddressData && validDisplayName);
return (validGeometry && validAddressData && validDisplayName);
};
 
TbPlaces.prototype.onSuggestionSelected = function() {
193,12 → 182,12
if (0 === $('#tb-places-error').length) {
this.places.closest('#tb-places-zone').after(
`<span id="tb-places-error" class="error mb-3 mt-3">
Votre recherche n’a pas donné de résultat pour le moment.<br>Vous pouvez soit poursuivre ou modifier votre recherche,<br>soit rechercher votre station directement sur la carte.
Votre recherche n’a rien donné.<br>veuillez modifier votre recherche ou rechercher votre station directement sur la carte.
</span>`
);
setTimeout(function() {
$('#tb-places-error').remove();
}, 10000);
}, 5000);
}
};
 
/branches/v3.01-serpe/widget/modules/saisie/squelettes/js/WidgetSaisie.js
382,8 → 382,8
valOk( locDatas.centroid.coordinates[0] ) &&
valOk( locDatas.centroid.coordinates[1] )
) {
longitude = locDatas.centroid.coordinates[0];
latitude = locDatas.centroid.coordinates[1];
latitude = locDatas.centroid.coordinates[0];
longitude = locDatas.centroid.coordinates[1];
}
if ( valOk( locDatas.inseeData ) ) {
nomCommune = locDatas.inseeData.nom;
/branches/v3.01-serpe/widget/modules/saisie/squelettes/js/ReleveASL.js
620,8 → 620,8
valOk( locDatas.centroid.coordinates[0] ) &&
valOk( locDatas.centroid.coordinates[1] )
) {
longitude = locDatas.centroid.coordinates[0];
latitude = locDatas.centroid.coordinates[1];
latitude = locDatas.centroid.coordinates[0];
longitude = locDatas.centroid.coordinates[1];
}
if ( !isGeolocArbres ) {
if ( valOk( locDatas.inseeData ) ) {