[gnome-maps/wip/mlundblad/maps-uri: 6/11] photonGeocode: Only include the location params when requested




commit a8150eab4ec96d4fc63cd1359afbdf5ab3e91a58
Author: Marcus Lundblad <ml update uu se>
Date:   Fri Oct 29 23:06:12 2021 +0200

    photonGeocode: Only include the location params when requested
    
    Only include the latitude and longitude parameters
    when specified as non-null in the call.

 src/photonGeocode.js | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
---
diff --git a/src/photonGeocode.js b/src/photonGeocode.js
index 0de55dd2..38d88ca2 100644
--- a/src/photonGeocode.js
+++ b/src/photonGeocode.js
@@ -135,10 +135,12 @@ var PhotonGeocode = class {
     }
 
     _buildURL(string, latitude, longitude) {
-        let query = new HTTP.Query({ lat:     latitude,
-                                     lon:     longitude,
-                                     limit:   string ? this._limit : 1
-                                   });
+        let query = new HTTP.Query({ limit: string ? this._limit : 1 });
+
+        if (latitude !== null && longitude != null) {
+            query.add('lat', latitude);
+            query.add('lon', longitude);
+        }
 
         if (string)
             query.add('q', string);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]