diff --git a/www/plugins/es/js/services/geo-services.js b/www/plugins/es/js/services/geo-services.js index f3591568af7322650f253feb389b557f807e06b7..960977828319dfa65a18fa5c2e281d3369bde617 100644 --- a/www/plugins/es/js/services/geo-services.js +++ b/www/plugins/es/js/services/geo-services.js @@ -28,7 +28,13 @@ angular.module('cesium.es.geo.services', ['cesium.services', 'cesium.es.http.ser apiKey: undefined, search: csHttp.get('maps.google.com', 443, '/maps/api/geocode/json') }, - searchByIP: csHttp.get('freegeoip.net', 443, '/json/:ip') + freegeoip: { + search: csHttp.get('freegeoip.net', 443, '/json/:ip'), + license: { + name: 'freegeoip', + url: 'https://freegeoip.net' + } + } }; function _normalizeAddressString(text) { @@ -148,10 +154,13 @@ angular.module('cesium.es.geo.services', ['cesium.services', 'cesium.es.http.ser //var now = new Date(); //console.debug('[ES] [geo] Searching IP position [{0}]...'.format(ip)); - return that.raw.searchByIP({ip: ip}) + return that.raw.freegeoip.search({ip: ip}) .then(function(res) { //console.debug('[ES] [geo] Found IP {0} position in {0}ms'.format(res ? 1 : 0, new Date().getTime() - now.getTime())); - return res ? {lat: res.latitude,lng: res.longitude} : undefined; + return res ? { + lat: res.latitude, + lng: res.longitude + } : undefined; }); } @@ -196,8 +205,11 @@ angular.module('cesium.es.geo.services', ['cesium.services', 'cesium.es.http.ser point: { current: getCurrentPosition, searchByAddress: searchPositionByAddress, - searchByIP: searchPositionByIP, - distance: getDistance + distance: getDistance, + ip: { + search: searchPositionByIP, + license: that.raw.freegeoip.license + } }, google: { isEnable: function() { diff --git a/www/plugins/map/js/controllers/network-controllers.js b/www/plugins/map/js/controllers/network-controllers.js index 7af3489df03c854515f6c2318774460406e406e8..6ee819bc72ddd77874c9160fc906c7ba8b9fa872 100644 --- a/www/plugins/map/js/controllers/network-controllers.js +++ b/www/plugins/map/js/controllers/network-controllers.js @@ -221,6 +221,13 @@ angular.module('cesium.map.network.controllers', ['cesium.services', 'cesium.map angular.extend(layer, L.featureGroup.subGroup(markerClusterLayer)); } }); + if (esGeo.point.ip.license) { + markerClusterLayer.getAttribution = function() { + return '<a target=\"_blank\" href="{0}">{1}</a>'.format( + esGeo.point.ip.license.url, + esGeo.point.ip.license.name); + }; + } markerClusterLayer.addTo(map); //$scope.map.layers.overlays['offline'].visible=false; @@ -255,7 +262,7 @@ angular.module('cesium.map.network.controllers', ['cesium.services', 'cesium.map // Get position by IP var bma = peer.bma; var address = peer.hasValid4(bma) ? bma.ipv4 : (bma.dns || bma.ipv6); - esGeo.point.searchByIP(address) + esGeo.point.ip.search(address) // Create the marker .then(function(position){// Add marker to list