From 6353b5e144fd21ef988abdf04c97e63689f58da4 Mon Sep 17 00:00:00 2001 From: Iván Ávalos Date: Wed, 8 Dec 2021 00:41:16 -0600 Subject: Added Google Maps layers --- modern/craco.config.js | 5 +++++ modern/src/map/Map.js | 13 ++++--------- modern/src/map/mapStyles.js | 8 ++++++++ web/l10n/en.json | 3 +++ web/l10n/es.json | 6 ++++++ 5 files changed, 26 insertions(+), 9 deletions(-) diff --git a/modern/craco.config.js b/modern/craco.config.js index 32971f2..c598595 100644 --- a/modern/craco.config.js +++ b/modern/craco.config.js @@ -1,4 +1,9 @@ module.exports = { + devServer: { + watchOptions: { + ignored: /\.#|node_modules|~$/, + }, + }, webpack: { configure: (webpackConfig) => { const scopePluginIndex = webpackConfig.resolve.plugins.findIndex( diff --git a/modern/src/map/Map.js b/modern/src/map/Map.js index 10630d8..d71a40b 100644 --- a/modern/src/map/Map.js +++ b/modern/src/map/Map.js @@ -8,10 +8,9 @@ import { SwitcherControl } from './switcher/switcher'; import deviceCategories from '../common/deviceCategories'; import { prepareIcon, loadImage } from './mapUtil'; import { - styleCarto, styleLocationIq, styleMapbox, styleMapTiler, styleOsm, + styleLocationIq, styleCarto, styleOsm, styleGmapsStreets, styleGmapsSatellite, styleGmapsHybrid } from './mapStyles'; import { useAttributePreference } from '../common/preferences'; -import palette from '../theme/palette'; import { useTranslation } from '../LocalizationProvider'; const element = document.createElement('div'); @@ -98,15 +97,11 @@ const Map = ({ children }) => { useEffect(() => { switcher.updateStyles([ { id: 'locationIqStreets', title: t('mapLocationIqStreets'), uri: styleLocationIq('streets', locationIqKey) }, - { id: 'locationIqEarth', title: t('mapLocationIqEarth'), uri: styleLocationIq('earth', locationIqKey) }, - { id: 'locationIqHybrid', title: t('mapLocationIqHybrid'), uri: styleLocationIq('hybrid', locationIqKey) }, { id: 'osm', title: t('mapOsm'), uri: styleOsm() }, { id: 'carto', title: t('mapCarto'), uri: styleCarto() }, - { id: 'mapboxStreets', title: t('mapMapboxStreets'), uri: styleMapbox('streets-v11') }, - { id: 'mapboxOutdoors', title: t('mapMapboxOutdoors'), uri: styleMapbox('outdoors-v11') }, - { id: 'mapboxSatellite', title: t('mapMapboxSatellite'), uri: styleMapbox('satellite-v9') }, - { id: 'mapTilerBasic', title: t('mapMapTilerBasic'), uri: styleMapTiler('basic', mapTilerKey) }, - { id: 'mapTilerHybrid', title: t('mapMapTilerHybrid'), uri: styleMapTiler('hybrid', mapTilerKey) }, + { id: 'gmapsStreets', title: t('mapGmapsStreets'), uri: styleGmapsStreets() }, + { id: 'gmapsSatellite', title: t('mapGmapsSatellite'), uri: styleGmapsSatellite() }, + { id: 'gmapsHybrid', title: t('mapGmapsHybrid'), uri: styleGmapsHybrid() }, ], 'locationIqStreets'); }, [mapTilerKey]); diff --git a/modern/src/map/mapStyles.js b/modern/src/map/mapStyles.js index 86813a1..a6e84fd 100644 --- a/modern/src/map/mapStyles.js +++ b/modern/src/map/mapStyles.js @@ -53,3 +53,11 @@ export const styleMapbox = (style) => `mapbox://styles/mapbox/${style}`; export const styleMapTiler = (style, key) => `https://api.maptiler.com/maps/${style}/style.json?key=${key}`; export const styleLocationIq = (style, key) => `https://tiles.locationiq.com/v3/${style}/vector.json?key=${key}`; + +// Google Maps + +export const styleGmapsStreets = () => styleCustom('https://mt0.google.com/vt/lyrs=m&hl=en&x={x}&y={y}&z={z}&s=Ga', ''); + +export const styleGmapsSatellite = () => styleCustom('https://mt0.google.com/vt/lyrs=s&hl=en&x={x}&y={y}&z={z}&s=Ga', ''); + +export const styleGmapsHybrid = () => styleCustom('https://mt0.google.com/vt/lyrs=y&hl=en&x={x}&y={y}&z={z}&s=Ga', ''); diff --git a/web/l10n/en.json b/web/l10n/en.json index ff5f61a..34585d2 100644 --- a/web/l10n/en.json +++ b/web/l10n/en.json @@ -249,6 +249,9 @@ "mapCustomLabel": "Custom map", "mapCarto": "Carto Basemaps", "mapOsm": "Open Street Map", + "mapGmapsStreets": "Google Maps Streets", + "mapGmapsSatellite": "Google Maps Satellite", + "mapGmapsHybrid": "Google Maps Hybrid", "mapBingKey": "Bing Maps Key", "mapBingRoad": "Bing Maps Road", "mapBingAerial": "Bing Maps Aerial", diff --git a/web/l10n/es.json b/web/l10n/es.json index fb93dc8..d981c73 100644 --- a/web/l10n/es.json +++ b/web/l10n/es.json @@ -247,8 +247,14 @@ "mapCustom": "Personalizado (XYZ)", "mapCustomArcgis": "ArcGIS Personalizado", "mapCustomLabel": "Mapa Personalizado", + "mapLocationIqStreets": "LocationIQ Calles", + "mapLocationIqEarth": "LocationIQ Satélite", + "mapLocationIqHybrid": "LocationIQ Híbrido", "mapCarto": "Mapas base Carto", "mapOsm": "Open Street Map", + "mapGmapsStreets": "Google Maps Calles", + "mapGmapsSatellite": "Google Maps Satélite", + "mapGmapsHybrid": "Google Maps Híbrido", "mapBingKey": "Bing Maps Key", "mapBingRoad": "Bing Maps - Carretera", "mapBingAerial": "Bing Maps - Aéreo", -- cgit v1.2.3