[gnome-maps/wip/mlundblad/maps-uri: 4/6] graphHopperGeocode: Only include location params when requested




commit 073ecb6a95ea9baaee011e7f34534ad9b9b6958b
Author: Marcus Lundblad <ml update uu se>
Date:   Fri Oct 29 23:04:29 2021 +0200

    graphHopperGeocode: Only include location params when requested
    
    Only include the the latitude and longitude parameters
    when set to non-null in the call.

 src/graphHopperGeocode.js | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
---
diff --git a/src/graphHopperGeocode.js b/src/graphHopperGeocode.js
index e63877e4..975cde2e 100644
--- a/src/graphHopperGeocode.js
+++ b/src/graphHopperGeocode.js
@@ -137,11 +137,13 @@ var GraphHopperGeocode = class {
     }
 
     _buildURL(string, latitude, longitude) {
-        let query = new HTTP.Query({ point:   latitude + ',' + longitude,
-                                     limit:   string ? this._limit : 1,
+        let query = new HTTP.Query({ limit:   string ? this._limit : 1,
                                      locale:  this._language,
                                      key:     this._apiKey
                                    });
+        if (latitude !== null && longitude != null)
+            query.add('point', latitude + ',' + longitude);
+
         if (string)
             query.add('q', string);
         else


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