diff --git a/assets/js/default/directory.js b/assets/js/default/directory.js index bf5ac1d0bcde7ec54d63009bcaab032ac40ba96d..e06daf377d0824ffa41a545309c3fa1af70f57c9 100755 --- a/assets/js/default/directory.js +++ b/assets/js/default/directory.js @@ -5381,16 +5381,19 @@ var directory = { return str; }, address : function(e, id, type, aObj){ - var localityHtml="",streetAddress='', postalCode = '', city='',str=''; + var localityHtml="",streetAddress='', postalCode = '', city='',str='', searchParams = ""; if (e.address != null) { streetAddress= e.address.streetAddress ? e.address.streetAddress : ''; postalCode = e.address.postalCode ? e.address.postalCode : ''; city = e.address.addressLocality ? e.address.addressLocality : '' ; } + if(typeof e.geo != "undefined"){ + searchParams = 'latLng='+e.geo.latitude+','+e.geo.longitude; + } localityHtml = (e.streetAddress != '' || e.postalCode!='' || e.city !='') ? streetAddress+' '+postalCode+' '+city : trad.UnknownLocality; var lbhN = "" ; - var urlH='#page.type.'+type+'.id.'+id; + var urlH= searchParams != "" ? `#search?${searchParams}` : '#page.type.'+type+'.id.'+id; var targetLink="target='_blank'"; if(typeof e.preview !="undefined" && e.preview){ targetLink=""; diff --git a/assets/js/default/filters.js b/assets/js/default/filters.js index bb643126db3d192547d05be7e39dfa1f16aa4ed1..c755a69ae323e5df4330b6d83422ec78bcbf8bae 100644 --- a/assets/js/default/filters.js +++ b/assets/js/default/filters.js @@ -197,6 +197,9 @@ var searchObj = { }, fitBounds:function(){ mapContext.fitBounds() + }, + zoomToElement: function(id, lat = null, lng = null){ + mapContext.zoomToElement(id, lat, lng) } } }else if(mapContext instanceof MapD3){ @@ -415,7 +418,7 @@ var searchObj = { fObj.filters.initDefaults(fObj, pInit); }, helpers: { - toggleMapVisibility: function(fObj){ + toggleMapVisibility: function(fObj, zoomTo = null){ coInterface.initHtmlPosition(); if(fObj.results.map.active){ fObj.results.map.active=false; @@ -424,7 +427,7 @@ var searchObj = { fObj.search.loadEvent.active = "scroll"; fObj.search.loadEvent.bind = false; fObj.search.loadEvent.default = "pagination" - + delete fObj.results.map.zoomTo; $(fObj.mapObj.parentContainer).fadeOut(); //$(mapCO.hideContainer).show(); fObj.mapObj.map.invalidateSize(); @@ -437,6 +440,9 @@ var searchObj = { fObj.results.showLimitMessage(fObj); }else{ fObj.results.map.active=true; + if(zoomTo){ + fObj.results.map.zoomTo = zoomTo; + } $(fObj.mapObj.parentContainer).fadeIn(); //$(mapCO.hideContainer).hide(); @@ -451,6 +457,10 @@ var searchObj = { if(!fObj.results.map.sameAsDirectory && fObj.results.map.changedfilters){ fObj.results.map.changedfilters=false; fObj.search.init(fObj); + }else{ + if(zoomTo){ + fObj.mapObj.zoomToElement(zoomTo) + } } } } @@ -906,6 +916,14 @@ var searchObj = { $(fObj.mapObj.parentContainer).fadeIn(); // fObj.helpers.toggleMapVisibility(fObj); } + }else if(e=="latLng"){ + var latLng = v.split(","); + if(latLng.length == 2){ + fObj.results.map.active=true; + fObj.results.map.latLng = {lat:latLng[0], lng:latLng[1]}; + $(fObj.mapObj.parentContainer).fadeIn(); + mylog.log("latLng",fObj.results.map.latLng); + } }else if(e=="mode"){ $(".changeViews").removeClass("active"); $(".changeViews[data-mode^="+v+"]").addClass("active"); @@ -5629,7 +5647,14 @@ var searchObj = { } fObj.mapObj.addElts(results); fObj.mapObj.map.invalidateSize(); - fObj.mapObj.fitBounds(); + if(typeof fObj.results.map.zoomTo != "undefined"){ + fObj.mapObj.zoomToElement(fObj.results.map.zoomTo); + }else if(typeof fObj.results.map.latLng != "undefined"){ + mylog.log("searchObj.results.addToMap", fObj.results.map.latLng); + fObj.mapObj.zoomToElement(null, fObj.results.map.latLng.lat, fObj.results.map.latLng.lng); + }else{ + fObj.mapObj.fitBounds(); + } }, countResults : function(fObj){ mylog.log("searchObj.results.numberOfResults"); diff --git a/views/translation/trad.php b/views/translation/trad.php index 7b8b6a7acfc1e8740238fa72f8b3be33115c12d5..e82ef46d4698fabbcae5369b34bb4e751954b20a 100755 --- a/views/translation/trad.php +++ b/views/translation/trad.php @@ -1473,6 +1473,7 @@ var tradDynForm = { "clear":"<?php echo Yii::t("common","Clear") ?>", "cancel":"<?php echo Yii::t("form","Cancel") ?>", "mainLocality":"<?php echo Yii::t("common","Main locality") ?>", + "setMainLocality":"<?php echo Yii::t("common","Set as primary address") ?>", "secondLocality":"<?php echo Yii::t("common","Second locality") ?>", "freeinfourl":"<?php echo Yii::t("form","Free informations / urls") ?>", "addpoi":"<?php echo Yii::t("form","Create a point of interest") ?>",