UNPKG

qwc2

Version:
118 lines (116 loc) 3.06 kB
/** * Copyright 2015 GeoSolutions Sas * Copyright 2016-2024 Sourcepole AG * All rights reserved. * * This source code is licensed under the BSD-style license found in the * LICENSE file in the root directory of this source tree. */ import ReducerIndex from '../reducers/index'; import mapReducer from '../reducers/map'; ReducerIndex.register("map", mapReducer); export var CHANGE_MAP_VIEW = 'CHANGE_MAP_VIEW'; export var CONFIGURE_MAP = 'CONFIGURE_MAP'; export var CLICK_ON_MAP = 'CLICK_ON_MAP'; export var CHANGE_ZOOM_LVL = 'CHANGE_ZOOM_LVL'; export var PAN_TO = 'PAN_TO'; export var ZOOM_TO_EXTENT = 'ZOOM_TO_EXTENT'; export var ZOOM_TO_POINT = 'ZOOM_TO_POINT'; export var CHANGE_ROTATION = 'CHANGE_ROTATION'; export var TOGGLE_MAPTIPS = 'TOGGLE_MAPTIPS'; export var SET_DISPLAY_CRS = 'SET_DISPLAY_CRS'; export var SET_SNAPPING_CONFIG = 'SET_SNAPPING_CONFIG'; export function changeMapView(center, zoom, bbox, size, mapStateSource, projection) { return { type: CHANGE_MAP_VIEW, center: center, zoom: zoom, bbox: bbox, size: size, mapStateSource: mapStateSource, projection: projection }; } /** * @param crs {string} The map projection * @param scales {Array} List of map scales * @param view {Object} The map view, as follows: * {center: [x, y], zoom: ..., crs: ...} * or * {bounds: [xmin, ymin, xmax, ymax], crs: ...} */ export function configureMap(crs, scales, view, defaultdisplaycrs) { return { type: CONFIGURE_MAP, crs: crs, scales: scales, view: view, defaultdisplaycrs: defaultdisplaycrs }; } export function clickOnMap(clickData) { return { type: CLICK_ON_MAP, click: clickData }; } export function changeZoomLevel(zoomLvl, mapStateSource) { return { type: CHANGE_ZOOM_LVL, zoom: zoomLvl, mapStateSource: mapStateSource }; } export function panTo(pos, crs) { var rotation = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : undefined; return { type: PAN_TO, pos: pos, crs: crs, rotation: rotation }; } export function zoomToExtent(extent, crs) { var zoomOffset = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0; return { type: ZOOM_TO_EXTENT, extent: extent, crs: crs, zoomOffset: zoomOffset }; } export function zoomToPoint(pos, zoom, crs) { var rotation = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : undefined; return { type: ZOOM_TO_POINT, pos: pos, zoom: zoom, crs: crs, rotation: rotation }; } export function changeRotation(rotation) { return { type: CHANGE_ROTATION, rotation: rotation }; } export function toggleMapTips(active) { return { type: TOGGLE_MAPTIPS, active: active }; } export function setSnappingConfig(enabled, active) { return { type: SET_SNAPPING_CONFIG, enabled: enabled, active: active }; } export function setDisplayCrs(displayCrs) { return { type: SET_DISPLAY_CRS, displayCrs: displayCrs }; }