Subversion Repositories eFlore/Applications.cel

Rev

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

Rev 3857 Rev 3869
Line 67... Line 67...
67
};
67
};
Line 68... Line 68...
68
 
68
 
69
TbPlaces.prototype.launchSearch = function () {
69
TbPlaces.prototype.launchSearch = function () {
70
    if (!!this.places.val()) {
70
    if (!!this.places.val()) {
-
 
71
        const url = NOMINATIM_OSM_URL+'search',
71
        const url = NOMINATIM_OSM_URL+'search',
72
            params = {
-
 
73
                'q': this.places.val(),
-
 
74
                'format': 'json',
-
 
75
                'polygon_geojson': 1,
-
 
76
                'zoom': 17
Line 72... Line 77...
72
            params = {'q':  this.places.val()};
77
            };
73
 
78
 
74
        this.placeLabel.addClass('loading');
79
        this.placeLabel.addClass('loading');
75
        $.ajax({
80
        $.ajax({
Line 115... Line 120...
115
                    '</li>'
120
                    '</li>'
116
                );
121
                );
117
            }
122
            }
118
        }
123
        }
119
    });
124
    });
-
 
125
    if(0 < acceptedSuggestions.length) {
120
    this.placesResultsContainer.removeClass('hidden');
126
        this.placesResultsContainer.removeClass('hidden');
-
 
127
    } else {
-
 
128
        this.resetPlacesSearch();
-
 
129
    }
121
};
130
};
Line 122... Line 131...
122
 
131
 
123
TbPlaces.prototype.validateSuggestionData = function(suggestion) {
132
TbPlaces.prototype.validateSuggestionData = function(suggestion) {
-
 
133
    const validGeometry = undefined !== suggestion.lat && undefined !== suggestion.lon,
-
 
134
        typeLocalisation = this.places.data('typeLocalisation') || '',
124
    const validGeometry = undefined !== suggestion.lat && undefined !== suggestion.lon,
135
        validGeometryType = 'rue' === typeLocalisation ? 'LineString' === suggestion?.geojson.type : true,
125
        validAddressData = undefined !== suggestion.address,
136
        validAddressData = undefined !== suggestion.address,
Line 126... Line 137...
126
        validDisplayName = undefined !== suggestion['display_name'];
137
        validDisplayName = undefined !== suggestion['display_name'];
127
 
138
 
Line 128... Line 139...
128
    return (validGeometry && validAddressData && validDisplayName);
139
    return (validGeometry && validGeometryType && validAddressData && validDisplayName);
129
};
140
};
Line 180... Line 191...
180
TbPlaces.prototype.handleSearchError = function() {
191
TbPlaces.prototype.handleSearchError = function() {
181
    this.resetPlacesSearch();
192
    this.resetPlacesSearch();
182
    if (0 === $('#tb-places-error').length) {
193
    if (0 === $('#tb-places-error').length) {
183
        this.places.closest('#tb-places-zone').after(
194
        this.places.closest('#tb-places-zone').after(
184
            `<span id="tb-places-error" class="error mb-3 mt-3">
195
            `<span id="tb-places-error" class="error mb-3 mt-3">
185
                Votre recherche n’a rien donné.<br>veuillez modifier votre recherche ou rechercher votre station directement sur la carte.
196
                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.
186
            </span>`
197
            </span>`
187
        );
198
        );
188
        setTimeout(function() {
199
        setTimeout(function() {
189
            $('#tb-places-error').remove();
200
            $('#tb-places-error').remove();
190
        }, 5000);
201
        }, 10000);
191
    }
202
    }
192
};
203
};
Line 193... Line 204...
193
 
204
 
194
TbPlaces.prototype.resetPlacesSearch = function() {
205
TbPlaces.prototype.resetPlacesSearch = function() {