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




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

    photonGeocode: Only include the location params when set
    
    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]