Subversion Repositories eFlore/Applications.cel

Compare Revisions

Ignore whitespace Rev 3868 → Rev 3869

/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] )
) {
latitude = locDatas.centroid.coordinates[0];
longitude = locDatas.centroid.coordinates[1];
longitude = locDatas.centroid.coordinates[0];
latitude = 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] )
) {
latitude = locDatas.centroid.coordinates[0];
longitude = locDatas.centroid.coordinates[1];
longitude = locDatas.centroid.coordinates[0];
latitude = locDatas.centroid.coordinates[1];
}
if ( !isGeolocArbres ) {
if ( valOk( locDatas.inseeData ) ) {
/branches/v3.01-serpe/widget/modules/saisie/squelettes/js/Utils.js
180,14 → 180,13
const thisFieldKey = $( this ).data( 'key' ),
fileMimeType = $( this ).data( 'mime-type' ),
label = 'Aide pour : ' + $( this ).data( 'name' );
 
let content = '';
 
if( fileMimeType.match( 'image' ) ) {
const extention = fileMimeType.replace( /(?:imag)?e\/?/g , '' );
const extention = fileMimeType.replace( /(?:imag)?e\/?/g , '' );
 
content = '<img id="modale-aide-img" src="' + lthis.cheminFichiers + thisFieldKey + '.' + extention + '" style="" alt="' + thisFieldKey + '" />';
}
content = '<img id="modale-aide-img" src="' + lthis.cheminFichiers + thisFieldKey + '.' + extention + '" style="" alt="' + thisFieldKey + '" />';
}
lthis.activerModale( label, content );
});
};
/branches/v3.01-serpe/widget/modules/saisie/squelettes/js/tb-geoloc/js/modules/Locality.js
69,7 → 69,12
TbPlaces.prototype.launchSearch = function () {
if (!!this.places.val()) {
const url = NOMINATIM_OSM_URL+'search',
params = {'q': this.places.val()};
params = {
'q': this.places.val(),
'format': 'json',
'polygon_geojson': 1,
'zoom': 17
};
 
this.placeLabel.addClass('loading');
$.ajax({
117,15 → 122,21
}
}
});
this.placesResultsContainer.removeClass('hidden');
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 && validAddressData && validDisplayName);
return (validGeometry && validGeometryType && validAddressData && validDisplayName);
};
 
TbPlaces.prototype.onSuggestionSelected = function() {
182,12 → 193,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 rien donné.<br>veuillez modifier votre recherche ou rechercher votre station directement sur la carte.
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.
</span>`
);
setTimeout(function() {
$('#tb-places-error').remove();
}, 5000);
}, 10000);
}
};
 
/branches/v3.01-serpe/widget/modules/saisie/squelettes/js/tb-geoloc/js/Geoloc.js
202,7 → 202,6
this.onCoordinates();
};
 
 
Geoloc.prototype.reSetDrawControl = function() {
this.map.removeLayer(this.layer);
this.map.removeControl(this.drawControl);
360,7 → 359,7
Geoloc.prototype.formatPolyline = function (latLngs) {
const polyline = [];
 
latLngs.forEach(coordinates => polyline.push(Object.values(coordinates)));
latLngs.forEach(coordinates => polyline.push(Object.values(coordinates).reverse()));
 
return polyline;
};
409,7 → 408,9
url: url,
data: params,
success: function(locationData) {
lthis.loadGeolocation(coordinates,locationData,polyline);
locationData.centroid = lthis.formatPointTypeCoordinates(coordinates);
locationData.geojson = 'rue' === lthis.geometryFilter ? {type: 'LineString', coordinates: polyline} : locationData.centroid;
lthis.loadGeolocation(coordinates,locationData);
},
error: (err) => {
console.warn(err);
418,7 → 419,11
});
};
 
Geoloc.prototype.loadGeolocation = function(coordinates,locationData,polyline) {
Geoloc.prototype.formatPointTypeCoordinates = function(coordinates) {
return {type : 'Point', coordinates: Object.values(coordinates).reverse()};
};
 
Geoloc.prototype.loadGeolocation = function(coordinates,locationData) {
const lthis = this,
query = {
'lat': coordinates.lat,
431,7 → 436,7
data: query,
success: function (geoLocationData) {
lthis.triggerLocationEvent(
lthis.formatLocationEventObject(coordinates,geoLocationData,locationData,polyline)
lthis.formatLocationEventObject(locationData,geoLocationData)
);
lthis.geolocLabel.classList.remove('loading');
},
442,18 → 447,16
});
};
 
Geoloc.prototype.triggerLocationEvent = function (locationDataObject) {
const location = new CustomEvent('location', {detail: locationDataObject});
Geoloc.prototype.triggerLocationEvent = function(locationDataObject) {
const locationEvent = new CustomEvent('location', {detail: locationDataObject});
 
this.mapEl.dispatchEvent(location);
this.mapEl.dispatchEvent(locationEvent);
};
 
Geoloc.prototype.formatLocationEventObject = function(coordinates,geoLocationData,locationData,polyline) {
Geoloc.prototype.formatLocationEventObject = function(locationData,geoLocationData) {
const detail = {
centroid: {
type: 'Point',
coordinates: Object.values(coordinates)
},
centroid: locationData.centroid,
geometry: locationData.geojson,
elevation: geoLocationData.altitude,
inseeData: {
code: geoLocationData.code_zone,
462,7 → 465,7
osmCountry: locationData.address.country,
osmCountryCode: geoLocationData.code_pays,
osmCounty: locationData.address.county,
osmPostcode:locationData.address.postcode,
osmPostcode: locationData.address.postcode,
locality: this.getLocalityFromData(locationData),
locality: geoLocationData.nom,
osmRoad: locationData.address.road,
471,17 → 474,8
osmPlaceId: locationData.place_id
};
 
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) {
514,16 → 508,27
const locality = this.getLocalityFromData(localityData);
 
if(!!locality) {
const coordinates = {
const coordinates = this.formatCoordinates({
'lat' : localityData.lat,
'lng' : localityData.lon
};
});
 
if ('point' === this.geometryFilter) {
this.map.removeControl(this.drawControl);
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.loadGeolocation(coordinates,localityData);
}
this.zoom = 18;
this.handleNewLocation(coordinates);
}
};
 
544,4 → 549,4
if (this.map != null) {
this.map._leaflet_id = null;
}
};
};