Retour à la documentation
/**
* @class spw.widgets.SpwQuickAddressSearch
*/
define([
"dojo/_base/declare", "spw/api/SpwBaseTemplatedWidget", "dojo/dom-construct",
"dojo/text!./templates/SpwQuickAddressSearch.html", "dojo/text!./templates/SpwQuickAddressSearchItem.html",
"dojo/dom-style", "dojo/dom-geometry", "dojo/_base/lang", "dojo/_base/window", "dojo/on", "dojo/dom-class",
"spw/api/MessageManager", "dojo/i18n!./nls/SpwQuickAddressSearch", "spw/api/Utils", "esri/geometry/Point",
"spw/api/ProjectionManager", "dijit/Tooltip", "dojo/_base/array"
],
function(declare, SpwBaseTemplatedWidget, domConstruct, quickAddressSearchTmpl, quickAddressSearchItemTmpl,
domStyle, domGeom, lang, win, on, domClass, MessageManager, labels, Utils, Point, ProjectionManager,
Tooltip, array) {
return declare("spw.widgets.SpwQuickAddressSearch", [SpwBaseTemplatedWidget], /** @lends spw.widgets.SpwQuickAddressSearch.prototype */{
//@jsonSchema
jsonSchema: {
title:"Specific configuration",
type: "object",
description:"Ce widget permet de localiser une adresse ou un lieu en rentrant une chaîne de caractères. Lorsque la recherche est lancée, une liste de résultats est proposée à l'utilisateur. Si l'utilisateur sélectionne un des résultats proprosés, un zoom est effectué sur la carte pour afficher le résultat. Ce widget permet également à l'utilisateur de centrer la carte sur sa position actuelle via le bouton ressemblant à une cible.",
properties:{
geolocalisationApiUrl:{
type:"string",
required:true,
description:"Ce paramètre défini l'URL de l'API Javascript de géolocalisation utilisée par le widget.",
default:"//geoservices.wallonie.be/geolocalisation/js/SpwGeolocalisationApi.js"
},
inWidget: {
type: "boolean",
required: false,
default: false,
description: "Indique si le widget se trouve dans un autre widget (il prend alors moins de place, les bords bleus disparaissant)."
},
noTitle: {
type: "boolean",
required: false,
default: false,
description: "Permet de masquer le titre du widget."
},
goToMyPositionAtStart: {
type: "boolean",
required: false,
default: false,
description: "Indique si le widget doit zoomer à la position de l'utilisateur au démarrage."
},
useCors: {
type: "boolean",
required: false,
default: true,
description: "Indique s'il faut passer par une page proxy pour l'appel à l'API de géolocalisation."
},
httpsErrorMessage: {
type: "string",
required: false,
default: "Le navigateur Chrome bloque la géolocalisation pour les pages non sécurisées.",
description: "Définit le message d'erreur à afficher en cas d'erreur dûe à l'HTTPS."
}
}
},
widgetDocIgnoreProperties: ["isZipCodeSearch", "fourNumbersOnly", "apiSRID", "apiLoaded"],
//@jsonSchema
templateString: quickAddressSearchTmpl,
labels: labels,
apiLoaded: false,
geolocalisationApiUrl: '//geoservices.wallonie.be/geolocalisation/js/SpwGeolocalisationApi.js',
/* START widget config */
apiSRID: 31370,
// inWidget: false,
// noTitle: false,
// goToMyPositionAtStart: false,
useCors: true,
// httpsErrorMessage: 'Le navigateur Chrome bloque la géolocalisation pour les pages non sécurisées.',
//"widgetTitle": "Localiser",
// "className": "SpwQuickAddressSearchV3",
// "position": "none",
// "geolocalisationApiUrl": "//geoservices.wallonie.be/geolocalisation/js/SpwGeolocalisationApi.js",
/* END widget config */
_hideResultListTimer: null,
/**
* @private
* @type Boolean
*/
_ignoreNextMouseOut: false,
/**
* Fonction à appeler lorsque l'utilisateur sélectionne un résultat.
* Elle recevra l'objet sélectionné en paramètre.
* Peut être initialisé dans le constructeur.
* <code>
* this._spwGeolocalisationSearchInput = new spw.impl.widgets.SpwGeolocalisationSearchInput({
* _resultClickedListener: this.onResultClicked
* });
* </code>
* @private
* @default null
* @type function
*/
_resultClickedListener: null,
/**
* Remplace la valeur du champ de recherche par la valeur de l'élément sélectionné par l'utilisateur.
* Peut être initialisé à true dans le constructeur ou par la méthode setReplaceSearchValueOnClickItem()
* <code>
* this._spwGeolocalisationSearchInput = new spw.impl.widgets.SpwGeolocalisationSearchInput({
* _resultClickedListener: this.onResultClicked
* });
* </code>
* @private
* @default false
* @type boolean
*/
_replaceSearchValueOnClickItem: false,
/**
* Liste des types d'objets proposés à l'utilisateur dans la liste des résultats.
* Peut être initialisé dans le constructeur avec les valeurs suivantes : 'POSITION','RUE','LOCALITE' et 'COMMUNE'.
* <code>
* this._spwGeolocalisationSearchInput = new spw.impl.widgets.SpwGeolocalisationSearchInput({
* _displayedTypes: ['POSITION','RUE']
* });
* </code>
* @private
* @default ['POSITION','RUE','LOCALITE','COMMUNE']
* @type Array
*/
_displayedTypes: ['POSITION','RUE','LOCALITE','COMMUNE'],
/**
* Boolean used to remember the type of the current search (We are waiting an answer from the server)
* If the value submitted matched fourNumbersOnly then it is set to true
*/
isZipCodeSearch: false,
/**
* RegExp used to check the kind if the value submitted to search is exaclyt made of of 4 numbers
*/
fourNumbersOnly: new RegExp('^\\d{4}$'),
_addressPointGraphic: null,
_addressPointSymbol: null,
postMixInProperties: function() {
this.inherited(arguments);
//Load data from geolocation services
require([this.geolocalisationApiUrl], lang.hitch(this, function(){
if(typeof(spwGeolocalisation) != "undefined"){
this.set('apiLoaded', true);
}
}));
},
postCreate: function(){
this.inherited(arguments);
//Load data from geolocation services
if(this.get('apiLoaded')){
this.initializeGeolocalisationApi();
} else {
this.watch("apiLoaded", lang.hitch(this, function(){
this.initializeGeolocalisationApi();
}));
}
new Tooltip({
connectId: this.myPositionNode,
label: labels.tooltipMyPosition,
position: ['below', 'after']
});
this.own(
on(this.myPositionNode, 'click', lang.hitch(this, this.goToMyPosition))
);
if (this.inWidget) {
domClass.add(this.domNode, 'inWidget');
}
if (this.noTitle) {
domStyle.set(this.titleNode, 'display', 'none');
}
if (this.goToMyPositionAtStart) {
this.goToMyPosition();
}
},
initializeGeolocalisationApi: function(){
if(typeof(spwGeolocalisation) != "undefined"){
if(this.useCors !== true) spwGeolocalisation.setProxyPage(this.spwViewer.get('proxyPageUrl'));
} else {
this._spwGeolocalisationSearchInputInput.disabled = "disabled";
this._spwGeolocalisationSearchInputInput.title = this.labels.geolocalisationServiceUnavailable;
domStyle.set(this._spwGeolocalisationSearchInputButton, {display: "none"});
}
var urlAdr = Utils.gua("ADR");
if(urlAdr && urlAdr != ""){
this._spwGeolocalisationSearchInputInput.value = decodeURIComponent(urlAdr).trim();
this.goToUrlAdress();
}
if(!this._resultClickedListener){
this._resultClickedListener = lang.hitch(this, function (data) {
this.spwViewer.trackEvent("spw.widgets.SpwQuickGeolocalisationWidget", "onResultClicked");
switch(data.type) {
case "POSITION":
var pt = ProjectionManager.getInstance().projectPoint(this.apiSRID, this.spwViewer.get('initialSpatialReference').wkid, data.x, data.y);
this.spwViewer.get('spwMap').zoomToPoint(pt.x, pt.y, 50);
break;
case "RUE":
case "LOCALITE":
case "COMMUNE":
var min = ProjectionManager.getInstance().projectPoint(this.apiSRID, this.spwViewer.get('initialSpatialReference').wkid, data.xMin, data.yMin);
var max = ProjectionManager.getInstance().projectPoint(this.apiSRID, this.spwViewer.get('initialSpatialReference').wkid, data.xMax, data.yMax);
this.spwViewer.get('spwMap').zoomToBbox(min.x, max.x, min.y, max.y);
break;
default:
break;
}
});
}
},
goToMyPosition: function() {
if(navigator.geolocation) {
if (!this.spwViewer.get('spwMap').loaded) {
on.once(this.spwViewer.get('spwMap'), 'MapLoaded', lang.hitch(this, this.goToMyPosition));
return;
}
navigator.geolocation.getCurrentPosition(
lang.hitch(this, function(location) {
var pt = ProjectionManager.getInstance().projectPoint('4326', this.spwViewer.get('initialSpatialReference').wkid,
location.coords.longitude, location.coords.latitude);
this.spwViewer.get('spwMap').zoomToPoint(pt.x, pt.y, 100, this.spwViewer.get('initialSpatialReference').wkid);
}),
lang.hitch(this, function(error) {
if(error && error.message && error.message.indexOf("Only secure origins are allowed") == 0) {
MessageManager.getInstance().notifyError(this.httpsErrorMessage);
}
else {
MessageManager.getInstance().notifyError(lang.replace(this.labels.geolocError, error));
}
console.error(error);
})
);
}
else {
MessageManager.getInstance().notifyError(this.labels.notSupported);
}
},
goToUrlAdress: function(){
this.emptyResultList();
if( this._spwGeolocalisationSearchInputInput.value != this.labels.defaultAdresseInputValue &&
this._spwGeolocalisationSearchInputInput.value.replace(/^\s\s*/, '').replace(/\s\s*$/, '').replace (/\./g, '') != "") {
if(this.fourNumbersOnly.test(this._spwGeolocalisationSearchInputInput.value)){
this.isZipCodeSearch = true;
}
this.spwViewer.trackEvent("spw.widgets.SpwGeolocalisationSearchInput", "executeSearchAll", this._spwGeolocalisationSearchInputInput.value);
this.displayWaitingLogo();
spwGeolocalisation.searchAll(
this._spwGeolocalisationSearchInputInput.value,
lang.hitch(this, function(data) {
this.hideWaitingLogo();
if(data.errorCode == 0 && data.resultats.length > 0) {
var params = this.extractUrlParams();
if(data.resultats[0].x && data.resultats[0].y){
var point = new Point(data.resultats[0].x, data.resultats[0].y, {wkid: 31370});
if (point.spatialReference.wkid != this.spwViewer.get('spwMap').getSpatialReferenceSRID()) {
point = this.spwViewer.get('spwMap').getEsriPointFromXYWkid(point.x, point.y, point.spatialReference.wkid);
}
this.spwViewer.get('spwMap').addMarkerOnPoint(point, params, true);
} else if(data.resultats[0].xMin && data.resultats[0].xMax && data.resultats[0].yMin && data.resultats[0].yMax) {
var point = new Point(
(data.resultats[0].xMin + data.resultats[0].xMax) / 2,
(data.resultats[0].yMin + data.resultats[0].yMax) / 2,
{wkid: 31370});
if (point.spatialReference.wkid != this.spwViewer.get('spwMap').getSpatialReferenceSRID()) {
point = this.spwViewer.get('spwMap').getEsriPointFromXYWkid(point.x, point.y, point.spatialReference.wkid);
}
var pointMin = new Point(data.resultats[0].xMin, data.resultats[0].yMin, {wkid: 31370});
var pointMax = new Point(data.resultats[0].xMax, data.resultats[0].yMax, {wkid: 31370});
if (pointMin.spatialReference.wkid != this.spwViewer.get('spwMap').getSpatialReferenceSRID()) {
pointMin = this.spwViewer.get('spwMap').getEsriPointFromXYWkid(pointMin.x, pointMin.y, pointMin.spatialReference.wkid);
}
if (pointMax.spatialReference.wkid != this.spwViewer.get('spwMap').getSpatialReferenceSRID()) {
pointMax = this.spwViewer.get('spwMap').getEsriPointFromXYWkid(pointMax.x, pointMax.y, pointMax.spatialReference.wkid);
}
this.spwViewer.get('spwMap').zoomToBbox(pointMin.x, pointMax.x, pointMin.y, pointMax.y, pointMin.spatialReference.wkid);
this.spwViewer.get('spwMap').addMarkerOnPoint(point, params);
} else {
MessageManager.getInstance().notifyError(this.labels.searchAllError + data.errorMsg + " (" + data.errorCode +")");
}
}
else {
MessageManager.getInstance().notifyError(this.labels.searchAllError + data.errorMsg + " (" + data.errorCode +")");
}
}),
lang.hitch(this, this.onSearchAllFault)
);
}
},
extractUrlParams: function() {
var coor = Utils.gua('ADR');
var params = {};
var stringParams = coor.split("|");
var streetName = "<div>"+decodeURIComponent(stringParams[0])+"</div>";
array.forEach(stringParams, lang.hitch(this, function(p, i) {
if (i != 0) {
var splittedP = p.split('=');
params[splittedP[0]] = splittedP[1];
}
}))
var options = Utils.buildLocalisableUrlParams(params);
options.text = streetName + options.text;
return options;
},
/**
* Active le remplacement de la valeur du champ de recherche par la valeur de l'élément sélectionné par l'utilisateur.
* @public
*/
setReplaceSearchValueOnClickItem: function() {
this._replaceSearchValueOnClickItem = true;
},
onKeyDownSpwGeolocalisationSearchInputInput: function(e) {
if(e && e.keyCode == 13) {
this.executeSearchAll();
}
},
executeSearchAll: function () {
if(typeof(spwGeolocalisation) == "undefined"){
MessageManager.getInstance().notifyError(this.labels.geolocalisationServiceUnavailable);
}
else {
this.unfocusInput();
this.emptyResultList();
if( this._spwGeolocalisationSearchInputInput.value != this.labels.defaultAdresseInputValue &&
this._spwGeolocalisationSearchInputInput.value.replace(/^\s\s*/, '').replace(/\s\s*$/, '').replace (/\./g, '') != "") {
if(this.fourNumbersOnly.test(this._spwGeolocalisationSearchInputInput.value)){
this.isZipCodeSearch = true;
}
this.spwViewer.trackEvent("spw.widgets.SpwGeolocalisationSearchInput", "executeSearchAll", this._spwGeolocalisationSearchInputInput.value);
this.displayWaitingLogo();
spwGeolocalisation.searchAll(
this._spwGeolocalisationSearchInputInput.value,
lang.hitch(this, this.onSearchAllResult),
lang.hitch(this, this.onSearchAllFault)
);
}
}
},
onSearchAllResult: function(data) {
this.hideWaitingLogo();
/*
*{"resultats":[
* {"type":"LOCALITE","cp":6987,"nom":"MARCOURT","xMin":232303.4406,"xMax":233420.9516,"yMin":100827.592999998,"yMax":101404.015299998},
* {"type":"LOCALITE","cp":6987,"nom":"MARCOURAY","xMin":233649.420500003,"xMax":234301.145499997,"yMin":100660.3609,"yMax":101340.279399998},
* {"type":"LOCALITE","cp":7500,"nom":"MOURCOURT","xMin":84251.2097000033,"xMax":85075.5429000035,"yMin":149197.6017,"yMax":149923.722199999}],
* "errorCode":0,"errorMsg":null}
*/
if(data.errorCode == 0) {
if(!this._spwGeolocalisationSearchInputResult) {
var inputPosition = domGeom.position(this._spwGeolocalisationSearchInputInput);
this._spwGeolocalisationSearchInputResult = domConstruct.create("div", {
style: {
top: (inputPosition.y + inputPosition.h) + "px",
left: (inputPosition.x) + "px"
}
}, win.body(), 'last');
domConstruct.create("div", {innerHTML: "Adresse", "class": "spwGeolocalisationItemsTitle"}, this._spwGeolocalisationSearchInputResult);
this._spwGeolocalisationSearchInputResultPOSITION = domConstruct.create("div", {"class": "spwGeolocalisationTypeWrapper"}, this._spwGeolocalisationSearchInputResult);
domConstruct.create("div", {innerHTML: "Route", "class": "spwGeolocalisationItemsTitle"}, this._spwGeolocalisationSearchInputResult);
this._spwGeolocalisationSearchInputResultRUE = domConstruct.create("div", {"class": "spwGeolocalisationTypeWrapper"}, this._spwGeolocalisationSearchInputResult);
domConstruct.create("div", {innerHTML: "Localité", "class": "spwGeolocalisationItemsTitle"}, this._spwGeolocalisationSearchInputResult);
this._spwGeolocalisationSearchInputResultLOCALITE = domConstruct.create("div", {"class": "spwGeolocalisationTypeWrapper"}, this._spwGeolocalisationSearchInputResult);
domConstruct.create("div", {innerHTML: "Commune", "class": "spwGeolocalisationItemsTitle"}, this._spwGeolocalisationSearchInputResult);
this._spwGeolocalisationSearchInputResultCOMMUNE = domConstruct.create("div", {"class": "spwGeolocalisationTypeWrapper"}, this._spwGeolocalisationSearchInputResult);
on(this._spwGeolocalisationSearchInputResult, "mouseover", lang.hitch(this, this.onDivMouseOver));
on(this._spwGeolocalisationSearchInputResult, "mouseout", lang.hitch(this, this.onDivMouseOut));
on(this._spwGeolocalisationSearchInputResult, "mousedown", lang.hitch(this, this.onDivMouseDown));
domClass.add(this._spwGeolocalisationSearchInputResult, "SpwGeolocalisationSearchInputResult");
}
if(data.resultats.length > 0) {
//on affiche le 1er de chaque type puis les autres
var t = null;
var alreadyDisplayedIndexes = new Array();
for(var i=0; i<data.resultats.length;i++) {
if(!t || t != data.resultats[i].type && this.isDisplayedType(data.resultats[i].type)) {
t = data.resultats[i].type;
alreadyDisplayedIndexes.push(i);
var spwGeolocalisationSearchInputResultItem = new this.SpwQuickAddressSearchItem({
labels: this.labels,
_data: data.resultats[i],
_parent: this
});
domConstruct.place(spwGeolocalisationSearchInputResultItem.domNode, this["_spwGeolocalisationSearchInputResult"+t], "last");
domConstruct.place(domConstruct.create("hr", {"class":"itemSeparator"}), spwGeolocalisationSearchInputResultItem.domNode, "after");
}
}
t = null;
var cptByType = 1;
for(var i=0; i<data.resultats.length;i++) {
if(this.isDisplayedType(data.resultats[i].type)) {
if((!t || t == data.resultats[i].type) && (cptByType < 3 || this.isZipCodeSearch)&& alreadyDisplayedIndexes.indexOf(i) == -1) {
t = data.resultats[i].type;
var spwGeolocalisationSearchInputResultItem = new this.SpwQuickAddressSearchItem({
labels: this.labels,
_data: data.resultats[i],
_parent: this
});
domConstruct.place(spwGeolocalisationSearchInputResultItem.domNode, this["_spwGeolocalisationSearchInputResult"+t], "last");
domConstruct.place(domConstruct.create("hr", {"class":"itemSeparator"}), spwGeolocalisationSearchInputResultItem.domNode, "after");
cptByType++;
}
else if(!t || t != data.resultats[i].type) {
t = data.resultats[i].type;
cptByType = 1;
}
}
}
if (this.isZipCodeSearch){
this.isZipCodeSearch = false;
}
if (this.onDisplayResult) {
this.onDisplayResult.call();
}
}
if(this._spwGeolocalisationSearchInputResultPOSITION.children.length == 0){
domConstruct.create("div", { "class": "SpwGeolocalisationSearchInputResultItem noResult", innerHTML: "Aucun résultat"}, this._spwGeolocalisationSearchInputResultPOSITION, "last");
}
if(this._spwGeolocalisationSearchInputResultRUE.children.length == 0){
domConstruct.create("div", { "class": "SpwGeolocalisationSearchInputResultItem noResult", innerHTML: "Aucun résultat"}, this._spwGeolocalisationSearchInputResultRUE, "last");
}
if(this._spwGeolocalisationSearchInputResultLOCALITE.children.length == 0){
domConstruct.create("div", { "class": "SpwGeolocalisationSearchInputResultItem noResult", innerHTML: "Aucun résultat"}, this._spwGeolocalisationSearchInputResultLOCALITE, "last");
}
if(this._spwGeolocalisationSearchInputResultCOMMUNE.children.length == 0){
domConstruct.create("div", { "class": "SpwGeolocalisationSearchInputResultItem noResult", innerHTML: "Aucun résultat"}, this._spwGeolocalisationSearchInputResultCOMMUNE, "last");
}
}
else {
MessageManager.getInstance().notifyError(this.labels.searchAllError + data.errorMsg + " (" + data.errorCode +")");
}
},
isDisplayedType: function(type) {
for(var i=0;i<this._displayedTypes.length;i++){
if(this._displayedTypes[i] == type) {
return true;
}
}
return false;
},
unfocusInput: function() {
//this._spwGeolocalisationSearchInputInput.blur();
this._spwGeolocalisationSearchInputButton.focus();
},
onDivMouseOver: function() {
this._ignoreNextMouseOut = false;
clearTimeout(this._hideResultListTimer);
},
onDivMouseOut: function() {
if(!this._ignoreNextMouseOut) {
this._hideResultListTimer = setTimeout(lang.hitch(this, this.hideResultList), 1000);
}
},
onDivMouseDown: function() {
this._ignoreNextMouseOut = true;
},
onSearchAllFault: function(request, status, error) {
this.hideWaitingLogo();
MessageManager.getInstance().notifyError(this.labels.searchAllError + error);
},
onClickSpwGeolocalisationSearchInputInput: function() {
if(this._spwGeolocalisationSearchInputInput.value == this.labels.defaultAdresseInputValue) {
this._spwGeolocalisationSearchInputInput.className = "SpwGeolocalisationSearchInputInputWorking";
this._spwGeolocalisationSearchInputInput.title = this.labels.searchAdressTooltip;
this._spwGeolocalisationSearchInputInput.value = "";
}
this.showResultList();
},
onBlurSpwGeolocalisationSearchInputInput: function() {
if(this._spwGeolocalisationSearchInputInput.value.replace(/^\s\s*/, '').replace(/\s\s*$/, '') == "") {
this._spwGeolocalisationSearchInputInput.className = "SpwGeolocalisationSearchInputInputDefault";
this._spwGeolocalisationSearchInputInput.value = this.labels.defaultAdresseInputValue;
}
this.onDivMouseOut();
},
onClickSpwGeolocalisationSearchInputButton: function() {
this.executeSearchAll();
},
onResultClicked : function (data, label) {
this.spwViewer.trackEvent("spw.widgets.SpwGeolocalisationSearchInput", "onResultClicked", label);
this.hideResultList();
if(this._replaceSearchValueOnClickItem) {
this._spwGeolocalisationSearchInputInput.value = label.replace(/<\/?[^>]+(>|$)/g, ' - ');
}
if(this._resultClickedListener) {
this._resultClickedListener(data);
}
},
/**
* Change le label du champ de recherche, en style grisé (travail en cours).
* @public
*/
setWorkingLabel: function(label) {
this._spwGeolocalisationSearchInputInput.value = label;
this._spwGeolocalisationSearchInputInput.className = "SpwGeolocalisationSearchInputInputWorking";
},
/**
* Change le label du champ de recherche, en style normal.
* @public
*/
setDefaultLabel: function(label) {
this._spwGeolocalisationSearchInputInput.value = label;
this._spwGeolocalisationSearchInputInput.className = "SpwGeolocalisationSearchInputInputDefault";
},
/**
* Réinitialise le composant.
* @public
*/
reset: function() {
this.emptyResultList();
this.setDefaultLabel(this.labels.defaultAdresseInputValue);
},
/**
* Vide la liste de résultats.
* @public
*/
emptyResultList : function() {
if(this._spwGeolocalisationSearchInputResult) {
domConstruct.empty(this._spwGeolocalisationSearchInputResultPOSITION);
domConstruct.empty(this._spwGeolocalisationSearchInputResultRUE);
domConstruct.empty(this._spwGeolocalisationSearchInputResultLOCALITE);
domConstruct.empty(this._spwGeolocalisationSearchInputResultCOMMUNE);
this.hideResultList();
this._spwGeolocalisationSearchInputResult = null;
}
},
/**
* Cache la liste de résultats.
* @public
*/
hideResultList : function () {
if(this._spwGeolocalisationSearchInputResult) {
this._spwGeolocalisationSearchInputResult.style.display = "none";
}
},
/**
* Affiche la liste de résultats.
* @public
*/
showResultList: function () {
if(this._spwGeolocalisationSearchInputResult) {
var inputPosition = domGeom.position(this._spwGeolocalisationSearchInputInput);
// domStyle.set(this._spwGeolocalisationSearchInputResult, {
// top: (inputPosition.y + inputPosition.h) + "px",
// left: (inputPosition.x) + "px"
// });
this._spwGeolocalisationSearchInputResult.style.display = "";
}
},
/**
* Affiche le logo de chargement.
* @public
*/
displayWaitingLogo: function() {
domClass.add(this._spwGeolocalisationSearchInputButton, "searching");
},
/**
* Cache le logo de chargement.
* @public
*/
hideWaitingLogo: function() {
domClass.remove(this._spwGeolocalisationSearchInputButton, "searching");
},
/**
* Renvoie le label du champ de recherche.
* @public
*/
getLabel: function() {
return this._spwGeolocalisationSearchInputInput.value;
},
SpwQuickAddressSearchItem: declare("spw.widgets.SpwQuickAddressSearchItem", [SpwBaseTemplatedWidget], {
templateString: quickAddressSearchItemTmpl,
_data: null,
_label: "",
_parent: null,
postMixInProperties: function() {
this.inherited(arguments);
switch(this._data.type) {
case "POSITION":
this._label = this._data.adresse;
break;
case "RUE":
if(this._data.localites && this._data.localites[0]) {
this._label = this._data.nom + "<br/>" + this._data.cps.join(", ") + " " + this._data.localites.join(", ");
}
else {
this._label = this._data.nom + "<br/>" + this._data.cps.join(", ") + " " + this._data.commune;
}
break;
case "LOCALITE":
this._label = this._data.nom + " " + this._data.cps.join(", ");
break;
case "COMMUNE":
this._label = "<b>" + this._data.nom + "</b> " + this._data.cps.join(", ");
break;
default: this._label = this._data;
break;
}
if (typeof this._data!="undefined"){
this._data.adresse=this._label;
}
},
onClick : function () {
this._parent.onResultClicked(this._data, this._label);
}
})
});
});