From 8bd4651f7c635951b75734f36b114846082e6744 Mon Sep 17 00:00:00 2001 From: Igor Zhukov Date: Wed, 28 Jun 2017 20:44:26 +0300 Subject: [PATCH] Migrate static maps to Yandex Yandex Static Maps API is free Closes #1415 --- app/js/directives.js | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/app/js/directives.js b/app/js/directives.js index d039e02a..c2e117a1 100755 --- a/app/js/directives.js +++ b/app/js/directives.js @@ -2411,18 +2411,23 @@ angular.module('myApp.directives', ['myApp.filters']) function link ($scope, element, attrs) { var width = element.attr('width') || 200 var height = element.attr('height') || 200 - var apiKey = Config.ExtCredentials.gmaps.api_key var zoom = width > 200 ? 15 : 13 + var useGoogle = false + var src - element.attr('src', 'img/blank.gif') - - var src = 'https://maps.googleapis.com/maps/api/staticmap?sensor=false¢er=' + $scope.point['lat'] + ',' + $scope.point['long'] + '&zoom=' + zoom + '&size=' + width + 'x' + height + '&scale=2&markers=color:red|size:big|' + $scope.point['lat'] + ',' + $scope.point['long'] - var useApiKey = true - - if (useApiKey) { - src += '&key=' + apiKey + if (useGoogle) { + var apiKey = Config.ExtCredentials.gmaps.api_key + var useApiKey = true + src = 'https://maps.googleapis.com/maps/api/staticmap?sensor=false¢er=' + $scope.point['lat'] + ',' + $scope.point['long'] + '&zoom=' + zoom + '&size=' + width + 'x' + height + '&scale=2&markers=color:red|size:big|' + $scope.point['lat'] + ',' + $scope.point['long'] + if (useApiKey) { + src += '&key=' + apiKey + } + } else { + src = 'https://static-maps.yandex.ru/1.x/?l=map&ll=' + $scope.point['long'] + ',' + $scope.point['lat'] + '&z=' + zoom + '&size=' + width + ',' + height + '&scale=1&pt=' + $scope.point['long'] + ',' + $scope.point['lat'] + ',pm2rdm&lang=en_US' } + element.attr('src', 'img/blank.gif') + ExternalResourcesManager.downloadByURL(src).then(function (url) { element.attr('src', url.valueOf()) })