Explorar o código

[core] Add getAddressFromCoordinates to the HueGeo lib

Enrico Berti %!s(int64=10) %!d(string=hai) anos
pai
achega
8006b6f
Modificáronse 1 ficheiros con 12 adicións e 0 borrados
  1. 12 0
      desktop/core/src/desktop/static/desktop/js/hue.geo.js

+ 12 - 0
desktop/core/src/desktop/static/desktop/js/hue.geo.js

@@ -312,6 +312,18 @@ var HueGeo = {
       }
     });
   },
+  getAddressFromCoordinates: function (lat, lng, callback) {
+    var api = new NominatimAPI();
+    api.lookupAddress(lat + "," + lng, function (rawdata) {
+      if (rawdata.length > 1) {
+        callback(rawdata);
+      }
+      else {
+        callback(rawdata[0].display_name);
+      }
+    });
+  },
+
   getAddressCoordinates: function (address, callback) {
     var api = new NominatimAPI();
     api.lookupAddress(address, function (rawdata) {