ip addresses: replace Google Maps with Bing Maps.
Replace the Google map on the IP address show page with a Bing map. Bing doesn't require an API key, which makes it easier to deploy. The Google Maps API requires to you to whitelist the IP addresses and domains you plan to use with your API key, which is inconvenient for development because it means maps won't display unless you whitelist your development IPs.
This commit is contained in:
@@ -1,11 +1,13 @@
|
||||
module IpAddressesHelper
|
||||
def embedded_google_map(location, width, height, api_key: Danbooru.config.google_maps_api_key)
|
||||
# https://www.bing.com/maps/embed-a-map
|
||||
# https://docs.microsoft.com/en-us/bingmaps/articles/create-a-custom-map-url
|
||||
def embedded_map(lat, long, width, height, zoom: 10)
|
||||
tag.iframe(
|
||||
width: width,
|
||||
height: height,
|
||||
frameborder: 0,
|
||||
allowfullscreen: true,
|
||||
src: "https://www.google.com/maps/embed/v1/search?q=#{location}&key=#{api_key}"
|
||||
src: "https://www.bing.com/maps/embed?w=#{width}&h=#{height}&cp=#{lat}~#{long}&lvl=#{zoom}"
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -71,5 +71,5 @@
|
||||
</div>
|
||||
|
||||
<div class="ip-address-map">
|
||||
<%= embedded_google_map("#{ip_info.dig(:location, :latitude)},#{ip_info.dig(:location, :longitude)}", 300, 200) %>
|
||||
<%= embedded_map(ip_info.dig(:location, :latitude), ip_info.dig(:location, :longitude), 300, 200) %>
|
||||
</div>
|
||||
|
||||
@@ -486,12 +486,6 @@ module Danbooru
|
||||
[]
|
||||
end
|
||||
|
||||
# API key for Google Maps. Used for embedding maps on IP address lookup pages.
|
||||
# Generate at https://console.developers.google.com/apis/credentials
|
||||
def google_maps_api_key
|
||||
nil
|
||||
end
|
||||
|
||||
# Cloudflare API token. Used to purge URLs from Cloudflare's cache when a
|
||||
# post is replaced. The token must have 'zone.cache_purge' permissions.
|
||||
# https://support.cloudflare.com/hc/en-us/articles/200167836-Managing-API-Tokens-and-Keys
|
||||
|
||||
@@ -34,7 +34,6 @@ services:
|
||||
- DANBOORU_RAKISMET_KEY
|
||||
- DANBOORU_RAKISMET_URL
|
||||
- DANBOORU_IP_REGISTRY_API_KEY
|
||||
- DANBOORU_GOOGLE_MAPS_API_KEY
|
||||
depends_on:
|
||||
- postgres
|
||||
user: root
|
||||
|
||||
Reference in New Issue
Block a user