diff --git a/plugins/Bookmark.jsx b/plugins/Bookmark.jsx
index 0f8b2c189..c02a48581 100644
--- a/plugins/Bookmark.jsx
+++ b/plugins/Bookmark.jsx
@@ -13,16 +13,17 @@ import classnames from 'classnames';
import isEmpty from 'lodash.isempty';
import PropTypes from 'prop-types';
+import { zoomToExtent, zoomToPoint } from '../actions/map';
import Icon from '../components/Icon';
import SideBar from '../components/SideBar';
import Spinner from '../components/Spinner';
import ConfigUtils from '../utils/ConfigUtils';
import LocaleUtils from '../utils/LocaleUtils';
-import {createBookmark, getUserBookmarks, removeBookmark, updateBookmark} from '../utils/PermaLinkUtils';
+import MapUtils from '../utils/MapUtils';
+import {createBookmark, getUserBookmarks, removeBookmark, resolveBookmark, updateBookmark} from '../utils/PermaLinkUtils';
import './style/Bookmark.css';
-
/**
* Allows managing user bookmarks.
*
@@ -32,10 +33,14 @@ import './style/Bookmark.css';
*/
class Bookmark extends React.Component {
static propTypes = {
+ mapCrs: PropTypes.string,
+ mapScales: PropTypes.array,
/** The side of the application on which to display the sidebar. */
side: PropTypes.string,
state: PropTypes.object,
- task: PropTypes.string
+ task: PropTypes.string,
+ zoomToExtent: PropTypes.func,
+ zoomToPoint: PropTypes.func
};
static defaultProps = {
side: 'right'
@@ -52,6 +57,7 @@ class Bookmark extends React.Component {
render() {
const openTitle = LocaleUtils.tr("bookmark.open");
const openTabTitle = LocaleUtils.tr("bookmark.openTab");
+ const zoomTitle = LocaleUtils.tr("bookmark.zoomToExtent");
const username = ConfigUtils.getConfigProp("username");
const placeholder = LocaleUtils.tr("bookmark.description");
const addBookmarkTitle = LocaleUtils.tr("bookmark.add");
@@ -80,6 +86,9 @@ class Bookmark extends React.Component {
+
@@ -121,6 +130,19 @@ class Bookmark extends React.Component {
location.href = url;
}
};
+ zoomToBookmarkExtent = (bookmarkkey) => {
+ resolveBookmark(bookmarkkey, (params) => {
+ if ('c' in params && 's' in params) {
+ const scale = parseFloat(params.s);
+ const zoom = MapUtils.computeZoom(this.props.mapScales, scale);
+ const center = params.c.split(/[;,]/g).map(x => parseFloat(x));
+ this.props.zoomToPoint(center, zoom, params.crs ?? this.props.mapCrs);
+ } else if ('e' in params) {
+ const bounds = (params.e).split(',').map(n => parseFloat(n));
+ this.props.zoomToExtent(bounds, params.crs ?? this.props.mapCrs);
+ }
+ });
+ };
toggleCurrentBookmark = (bookmark) => {
if (this.state.currentBookmark === bookmark.key) {
this.setState({currentBookmark: null, description: ""});
@@ -166,8 +188,13 @@ class Bookmark extends React.Component {
}
const selector = state => ({
+ mapCrs: state.map.projection,
+ mapScales: state.map.scales,
task: state.task.id,
state
});
-export default connect(selector)(Bookmark);
+export default connect(selector, {
+ zoomToExtent: zoomToExtent,
+ zoomToPoint: zoomToPoint
+})(Bookmark);
diff --git a/translations/ca-ES.json b/translations/ca-ES.json
index 0bd761127..dbe584e7a 100644
--- a/translations/ca-ES.json
+++ b/translations/ca-ES.json
@@ -83,7 +83,8 @@
"remove": "Esborrar",
"removefailed": "Error al eliminar",
"savefailed": "Error al modificar",
- "update": "Updatejar"
+ "update": "Updatejar",
+ "zoomToExtent": ""
},
"bottombar": {
"mousepos_label": "Coordenades",
diff --git a/translations/cs-CZ.json b/translations/cs-CZ.json
index 5079fb8af..847feef88 100644
--- a/translations/cs-CZ.json
+++ b/translations/cs-CZ.json
@@ -83,7 +83,8 @@
"remove": "Smazat",
"removefailed": "Mazání záložky selhalo",
"savefailed": "Ukládání záložky selhalo",
- "update": "Upravit"
+ "update": "Upravit",
+ "zoomToExtent": ""
},
"bottombar": {
"mousepos_label": "Souřadnice",
diff --git a/translations/de-CH.json b/translations/de-CH.json
index 6cba8f3c0..c930e4bc3 100644
--- a/translations/de-CH.json
+++ b/translations/de-CH.json
@@ -83,7 +83,8 @@
"remove": "Lesezeichen entfernen",
"removefailed": "Lesezeichen konnte nicht entfernt werden",
"savefailed": "Lesezeichen konnte nicht aktualisiert werden",
- "update": "Lesezeichen aktualisieren"
+ "update": "Lesezeichen aktualisieren",
+ "zoomToExtent": ""
},
"bottombar": {
"mousepos_label": "Koordinaten",
diff --git a/translations/de-DE.json b/translations/de-DE.json
index 6d0d6bd33..fba49efb4 100644
--- a/translations/de-DE.json
+++ b/translations/de-DE.json
@@ -83,7 +83,8 @@
"remove": "Lesezeichen entfernen",
"removefailed": "Lesezeichen konnte nicht entfernt werden",
"savefailed": "Lesezeichen konnte nicht aktualisiert werden",
- "update": "Lesezeichen aktualisieren"
+ "update": "Lesezeichen aktualisieren",
+ "zoomToExtent": ""
},
"bottombar": {
"mousepos_label": "Koordinaten",
diff --git a/translations/en-US.json b/translations/en-US.json
index c610182ff..fb320451e 100644
--- a/translations/en-US.json
+++ b/translations/en-US.json
@@ -83,7 +83,8 @@
"remove": "Remove bookmark",
"removefailed": "Failed to remove bookmark",
"savefailed": "Failed to update bookmark",
- "update": "Update bookmark"
+ "update": "Update bookmark",
+ "zoomToExtent": "Zoom to extent"
},
"bottombar": {
"mousepos_label": "Coordinates",
diff --git a/translations/es-ES.json b/translations/es-ES.json
index 4b8b947b1..2f02045a8 100644
--- a/translations/es-ES.json
+++ b/translations/es-ES.json
@@ -83,7 +83,8 @@
"remove": "Eliminar",
"removefailed": "Error al eliminar el marcador",
"savefailed": "Error al actualizar el marcador",
- "update": "Actualizar marcador"
+ "update": "Actualizar marcador",
+ "zoomToExtent": ""
},
"bottombar": {
"mousepos_label": "Coordenadas",
diff --git a/translations/fi-FI.json b/translations/fi-FI.json
index 6193ee3cc..7f146f140 100644
--- a/translations/fi-FI.json
+++ b/translations/fi-FI.json
@@ -83,7 +83,8 @@
"remove": "Poista kirjanmerkki",
"removefailed": "",
"savefailed": "",
- "update": "Päivitä kirjanmerkki"
+ "update": "Päivitä kirjanmerkki",
+ "zoomToExtent": ""
},
"bottombar": {
"mousepos_label": "Koordinaatit",
diff --git a/translations/fr-FR.json b/translations/fr-FR.json
index 9fc046dca..e51ca92fa 100644
--- a/translations/fr-FR.json
+++ b/translations/fr-FR.json
@@ -83,7 +83,8 @@
"remove": "Supprimer le marque-page",
"removefailed": "Echec de suppression du marque-page",
"savefailed": "Echec d'enregistrement du marque-page",
- "update": "Sauvegarder le marque-page"
+ "update": "Sauvegarder le marque-page",
+ "zoomToExtent": "Zommer sur l'étendue"
},
"bottombar": {
"mousepos_label": "Coordonnées",
diff --git a/translations/hu-HU.json b/translations/hu-HU.json
index f9a3a5345..c53ecf00f 100644
--- a/translations/hu-HU.json
+++ b/translations/hu-HU.json
@@ -83,7 +83,8 @@
"remove": "",
"removefailed": "",
"savefailed": "",
- "update": ""
+ "update": "",
+ "zoomToExtent": ""
},
"bottombar": {
"mousepos_label": "Koordináták",
diff --git a/translations/it-IT.json b/translations/it-IT.json
index 6936da3f9..64bf61b77 100644
--- a/translations/it-IT.json
+++ b/translations/it-IT.json
@@ -83,7 +83,8 @@
"remove": "Rimuovi segnalibro",
"removefailed": "Impossibile rimuovere il segnalibro",
"savefailed": "Impossibile aggiornare il segnalibro",
- "update": "Aggiorna segnalibro"
+ "update": "Aggiorna segnalibro",
+ "zoomToExtent": ""
},
"bottombar": {
"mousepos_label": "Coordinate",
diff --git a/translations/no-NO.json b/translations/no-NO.json
index 6d51b3594..6b1bd32f0 100644
--- a/translations/no-NO.json
+++ b/translations/no-NO.json
@@ -83,7 +83,8 @@
"remove": "",
"removefailed": "",
"savefailed": "",
- "update": ""
+ "update": "",
+ "zoomToExtent": ""
},
"bottombar": {
"mousepos_label": "Koordinater",
diff --git a/translations/pl-PL.json b/translations/pl-PL.json
index 486a95116..b280d39f5 100644
--- a/translations/pl-PL.json
+++ b/translations/pl-PL.json
@@ -83,7 +83,8 @@
"remove": "",
"removefailed": "",
"savefailed": "",
- "update": ""
+ "update": "",
+ "zoomToExtent": ""
},
"bottombar": {
"mousepos_label": "Współrzędne",
diff --git a/translations/pt-BR.json b/translations/pt-BR.json
index cd1980f95..c84efdc04 100644
--- a/translations/pt-BR.json
+++ b/translations/pt-BR.json
@@ -83,7 +83,8 @@
"remove": "Remover",
"removefailed": "Falha ao remover",
"savefailed": "Falha ao salvar",
- "update": "Atualizar"
+ "update": "Atualizar",
+ "zoomToExtent": ""
},
"bottombar": {
"mousepos_label": "Coordenadas",
diff --git a/translations/pt-PT.json b/translations/pt-PT.json
index 742fd3651..9af3082a7 100644
--- a/translations/pt-PT.json
+++ b/translations/pt-PT.json
@@ -83,7 +83,8 @@
"remove": "Remover",
"removefailed": "Falha ao Remover",
"savefailed": "Falha ao Guardar",
- "update": "Atualizar"
+ "update": "Atualizar",
+ "zoomToExtent": ""
},
"bottombar": {
"mousepos_label": "Coordenadas",
diff --git a/translations/ro-RO.json b/translations/ro-RO.json
index 461cd094b..e3c1a0944 100644
--- a/translations/ro-RO.json
+++ b/translations/ro-RO.json
@@ -83,7 +83,8 @@
"remove": "Elimină semn de carte",
"removefailed": "Semnul de carte nu a putut fi șters",
"savefailed": "Semnul de carte nu a putut fi salvat",
- "update": "Actualizează semnul de carte"
+ "update": "Actualizează semnul de carte",
+ "zoomToExtent": ""
},
"bottombar": {
"mousepos_label": "Coordonate",
diff --git a/translations/ru-RU.json b/translations/ru-RU.json
index e47a81c9e..7f785acfe 100644
--- a/translations/ru-RU.json
+++ b/translations/ru-RU.json
@@ -83,7 +83,8 @@
"remove": "",
"removefailed": "",
"savefailed": "",
- "update": ""
+ "update": "",
+ "zoomToExtent": ""
},
"bottombar": {
"mousepos_label": "Координаты",
diff --git a/translations/sv-SE.json b/translations/sv-SE.json
index 3ad9836bb..843872c58 100644
--- a/translations/sv-SE.json
+++ b/translations/sv-SE.json
@@ -83,7 +83,8 @@
"remove": "",
"removefailed": "",
"savefailed": "",
- "update": ""
+ "update": "",
+ "zoomToExtent": ""
},
"bottombar": {
"mousepos_label": "Koordinater",
diff --git a/translations/tr-TR.json b/translations/tr-TR.json
index dfbfa22be..3fd6eeca5 100644
--- a/translations/tr-TR.json
+++ b/translations/tr-TR.json
@@ -83,7 +83,8 @@
"remove": "",
"removefailed": "",
"savefailed": "",
- "update": ""
+ "update": "",
+ "zoomToExtent": ""
},
"bottombar": {
"mousepos_label": "Koordinatlar",
diff --git a/translations/tsconfig.json b/translations/tsconfig.json
index c16f4f3f7..995f6ae68 100644
--- a/translations/tsconfig.json
+++ b/translations/tsconfig.json
@@ -95,6 +95,7 @@
"bookmark.removefailed",
"bookmark.savefailed",
"bookmark.update",
+ "bookmark.zoomToExtent",
"bottombar.mousepos_label",
"bottombar.scale_label",
"bottombar.terms_label",
diff --git a/utils/PermaLinkUtils.js b/utils/PermaLinkUtils.js
index 7ddba83af..4dfdc4aa5 100644
--- a/utils/PermaLinkUtils.js
+++ b/utils/PermaLinkUtils.js
@@ -135,6 +135,17 @@ export function resolvePermaLink(initialParams, callback) {
}
}
+export function resolveBookmark(bookmarkKey, callback) {
+ axios.get(ConfigUtils.getConfigProp("permalinkServiceUrl").replace(/\/$/, '') + "/bookmarks/" + bookmarkKey)
+ .then(response => {
+ const data = response.data;
+ callback({...(data.query || {})}, (data.state || {}), !!data.query);
+ })
+ .catch(() => {
+ callback(bookmarkKey, {}, false);
+ });
+}
+
export function getUserBookmarks(user, callback) {
if (user) {
axios.get(ConfigUtils.getConfigProp("permalinkServiceUrl").replace(/\/$/, '') + "/bookmarks/")