From 445fae4d091b2c0bdc0b38b5d5c71ed6dcfa1d6c Mon Sep 17 00:00:00 2001 From: Maikel Linke Date: Tue, 16 Feb 2021 14:30:24 +1100 Subject: [PATCH] Use Google's map tiles with Google Maps We started to move to Open Street Maps (OSM) and one simple change was to show OSM tiles on top of the current Google Maps functionality. This hybrid use violates Google's terms and conditions though and I'm reverting it here (basically reverting daa5b00a2). Another branch of work was already started to use OSM without Google functionality and it's available behind a feature toggle. We can continue that work in our own time without a license violation. This change is only changing the tiles, the look of the map and doesn't touch any functionality which was always provided by Google Maps. --- .../directives/map_osm_tiles.js.coffee | 21 -------------- .../services/map_configuration.js.erb.coffee | 1 - app/assets/stylesheets/darkswarm/map.scss | 29 ------------------- app/views/shared/_map.html.haml | 4 --- 4 files changed, 55 deletions(-) delete mode 100644 app/assets/javascripts/darkswarm/directives/map_osm_tiles.js.coffee diff --git a/app/assets/javascripts/darkswarm/directives/map_osm_tiles.js.coffee b/app/assets/javascripts/darkswarm/directives/map_osm_tiles.js.coffee deleted file mode 100644 index 394236ce61..0000000000 --- a/app/assets/javascripts/darkswarm/directives/map_osm_tiles.js.coffee +++ /dev/null @@ -1,21 +0,0 @@ -Darkswarm.directive 'mapOsmTiles', ($timeout) -> - restrict: 'E' - require: '^uiGmapGoogleMap' - scope: {} - link: (scope, elem, attrs, ctrl) -> - $timeout => - map = ctrl.getMap() - - map.mapTypes.set 'OSM', new google.maps.ImageMapType - getTileUrl: (coord, zoom) -> - # "Wrap" x (logitude) at 180th meridian properly - # NB: Don't touch coord.x because coord param is by reference, and changing its x property breaks something in Google's lib - tilesPerGlobe = 1 << zoom - x = coord.x % tilesPerGlobe - if x < 0 - x = tilesPerGlobe + x - # Wrap y (latitude) in a like manner if you want to enable vertical infinite scroll - 'https://a.tile.openstreetmap.org/' + zoom + '/' + x + '/' + coord.y + '.png' - tileSize: new google.maps.Size(256, 256) - name: 'OpenStreetMap' - maxZoom: 18 diff --git a/app/assets/javascripts/darkswarm/services/map_configuration.js.erb.coffee b/app/assets/javascripts/darkswarm/services/map_configuration.js.erb.coffee index 61598c414c..ebfda75dd7 100644 --- a/app/assets/javascripts/darkswarm/services/map_configuration.js.erb.coffee +++ b/app/assets/javascripts/darkswarm/services/map_configuration.js.erb.coffee @@ -8,7 +8,6 @@ Darkswarm.factory "MapConfiguration", -> zoom: 12 additional_options: # mapTypeId: 'satellite' - mapTypeId: 'OSM' mapTypeControl: false streetViewControl: false styles: [{"featureType":"landscape","stylers":[{"saturation":-100},{"lightness":65},{"visibility":"on"}]},{"featureType":"poi","stylers":[{"saturation":-100},{"lightness":51},{"visibility":"simplified"}]},{"featureType":"road.highway","stylers":[{"saturation":-100},{"visibility":"simplified"}]},{"featureType":"road.arterial","stylers":[{"saturation":-100},{"lightness":30},{"visibility":"on"}]},{"featureType":"road.local","stylers":[{"saturation":-100},{"lightness":40},{"visibility":"on"}]},{"featureType":"transit","stylers":[{"saturation":-100},{"visibility":"simplified"}]},{"featureType":"administrative.province","stylers":[{"visibility":"off"}]},{"featureType":"water","elementType":"labels","stylers":[{"visibility":"on"},{"lightness":-25},{"saturation":-100}]},{"featureType":"water","elementType":"geometry","stylers":[{"hue":"#ffff00"},{"lightness":-25},{"saturation":-97}]},{"featureType":"road","elementType": "labels.icon","stylers":[{"visibility":"off"}]}] diff --git a/app/assets/stylesheets/darkswarm/map.scss b/app/assets/stylesheets/darkswarm/map.scss index 8f9ee717f9..b3a6d827ea 100644 --- a/app/assets/stylesheets/darkswarm/map.scss +++ b/app/assets/stylesheets/darkswarm/map.scss @@ -64,32 +64,3 @@ } } } - -.map-footer { - position: fixed; - z-index: 2; - width: 100%; - height: 23px; - left: 80px; - right: 0; - bottom: 6px; - margin: 0; - padding: 6px; - font-size: 14px; - font-weight: bold; - text-shadow: 2px 2px #aaa; - color: #fff; - - a, a:hover, a:active, a:focus { - color: #fff; - } - - @media all and (max-width: 1025px) { - left: 0px; - } -} - -.tabs-content .map-footer { - position: relative; - bottom: 30px; -} diff --git a/app/views/shared/_map.html.haml b/app/views/shared/_map.html.haml index c7df6d5b2b..f1b31ace3d 100644 --- a/app/views/shared/_map.html.haml +++ b/app/views/shared/_map.html.haml @@ -10,10 +10,6 @@ %map{"ng-controller" => "MapCtrl"} %ui-gmap-google-map{options: "map.additional_options", center: "map.center", zoom: "map.zoom", styles: "map.styles", draggable: "true"} - %map-osm-tiles %map-search %ui-gmap-markers{models: "OfnMap.enterprises", fit: "true", coords: "'self'", icon: "'icon'", click: "'reveal'"} - - .map-footer - %a{:href => "http://www.openstreetmap.org/copyright"} © OpenStreetMap contributors