geoview-core - v2.1.2
    Preparing search index...

    Class MapViewer

    Class used to manage created maps

    MapViewer

    Index

    Constructors

    Properties

    Accessors

    Methods

    addComponent addLocalizeRessourceBundle clickMarkerIconHide clickMarkerIconShow convertCoordinateFromMapProjToProj convertCoordinateFromProjToMapProj convertCoordinateLonLatToMapProj convertCoordinateMapProjToLonLat convertExtentFromMapProjToProj convertExtentFromProjToMapProj convertExtentLonLatToMapProj convertExtentMapProjToLonLat createMap createMapConfigFromMapState delete emitMapSingleClick getCenter getCoordinateFromPixel getCorePackageConfig getDisplayLanguage getDisplayTheme getGeolocatorSearchArea getI18nInstance getMapLayerOrderInfo getMapResolutionFromScale getMapScale getMapScaleFromZoom getMapSize getMapState getMapZoomFromScale getNorthArrowAngle getNorthPoleVisibility getPlugin getPluginAsync getProjection getView initDrawInteractions initExtentInteractions initMap initModifyInteractions initSelectInteractions initSnapInteractions initTransformInteractions initTranslateInteractions initTranslateOneFeatureInteractions offMapChangeSize offMapComponentAdded offMapComponentRemoved offMapInit offMapLanguageChanged offMapLayersLoaded offMapLayersProcessed offMapMoveEnd offMapPointerMove offMapPointerStop offMapProjectionChanged offMapReady offMapRotation offMapSingleClick offMapZoomEnd onMapChangeSize onMapComponentAdded onMapComponentRemoved onMapInit onMapLanguageChanged onMapLayersLoaded onMapLayersProcessed onMapMoveEnd onMapPointerMove onMapPointerStop onMapProjectionChanged onMapReady onMapRotation onMapSingleClick onMapZoomEnd registerMapPointerHandlers removeComponent replaceMapConfigLayerNames rotate setCenter setDisplayDateTimezone setExtent setFullscreen setHomeButtonView setInteraction setLanguage setMapZoomLevel setMaxExtent setMaxZoomLevel setMinZoomLevel setProjection setTheme setView simulateMapClick unregisterMapPointerHandlers updateIconImageCache waitAllLayersStatus waitForLayersLoaded waitForRender zoomToExtent zoomToInitialExtent zoomToLonLatExtentOrCoordinate

    Constructors

    • Constructor for a MapViewer, setting:

      • the mapId
      • the mapFeaturesConfig
      • i18n
      • AppBar, NavBar, FooterBar
      • modalApi
      • basemap

      Parameters

      Returns MapViewer

    Properties

    appBarApi: AppBarApi
    basemap: BasemapApi
    footerBarApi: FooterBarApi
    iconImageCacheSize: number
    layer: LayerApi
    map: Map
    mapFeaturesConfig: TypeMapFeaturesConfig
    mapId: string
    modal: ModalApi
    navBarApi: NavBarApi
    notifications: Notifications
    overviewRoot: Root | undefined
    plugins: PluginsContainer = {}
    stateApi: StateApi
    DEFAULT_DPI: number = MapViewer.DEFAULT_DPI_MODERN
    DEFAULT_DPI_MODERN: number = 96
    DEFAULT_DPI_OPEN_LAYERS_LEGACY: number = ...

    Default DPI values

    DEFAULT_INCHES_PER_METER: 39.3700787

    Default inches per meter used by OpenLayers

    DEFAULT_STOPS: number = 25

    Default densification number when forming layer extents, to make ture to compensate for earth curvature

    Accessors

    • get mapInit(): boolean

      Returns boolean

    • get mapLayersLoaded(): boolean

      Returns boolean

    • get mapLayersProcessed(): boolean

      Returns boolean

    • get mapReady(): boolean

      Returns boolean

    Methods

    • Add a new custom component to the map

      Parameters

      • mapComponentId: string

        An id to the new component

      • component: Element

        The component to add

      Returns void

    • Add a localization ressource bundle for a supported language (fr, en). Then the new key added can be access from the utilies function getLocalizesMessage to reuse in ui from outside the core viewer.

      Parameters

      • language: TypeDisplayLanguage

        The language to add the ressoruce for (en, fr)

      • translations: Record<string, unknown>

        The translation object to add

      Returns void

    • Hide a click marker from the map

      Returns void

    • Show a marker on the map

      Parameters

      Returns void

    • Transforms coordinate from map projection to given projection.

      Parameters

      • coordinate: Coordinate

        The given coordinate

      • toProj: Projection

        The projection that should be output

      Returns Coordinate

      The coordinate in the map projection

    • Transforms coordinate from given projection to the current projection of the map.

      Parameters

      • coordinate: Coordinate

        The given coordinate

      • fromProj: Projection

        The projection of the given coordinate

      Returns Coordinate

      The coordinate in the map projection

    • Transforms coordinate from LonLat to the current projection of the map.

      Parameters

      Returns Coordinate

      The coordinate in the map projection

    • Transforms coordinate from current projection of the map to LonLat.

      Parameters

      • coordinate: Coordinate

        The coordinate in map projection

      Returns Coordinate

      The coordinate in LonLat

    • Transforms extent from map projection to given projection. If the projects are the same, the extent is simply returned.

      Parameters

      • extent: Extent

        The given extent

      • toProj: Projection

        The projection that should be output

      • stops: number = MapViewer.DEFAULT_STOPS

      Returns Extent

      The extent in the map projection

    • Transforms extent from given projection to the current projection of the map.

      Parameters

      • extent: Extent

        The given extent

      • fromProj: Projection

        The projection of the given extent

      • stops: number = MapViewer.DEFAULT_STOPS

        The number of stops to perform densification on the extent

      Returns Extent

      The extent in the map projection

    • Transforms extent from LonLat to the current projection of the map.

      Parameters

      • extent: Extent

        The LonLat extent

      • stops: number = MapViewer.DEFAULT_STOPS

        The number of stops to perform densification on the extent

      Returns Extent

      The extent in the map projection

    • Transforms extent from current projection of the map to LonLat.

      Parameters

      • extent: Extent

        The extent in map projection

      Returns Extent

      The extent in LonLat

    • Create an Open Layer map from configuration attached to the class. This function is called from a useEffect and should be running synchronously.

      Parameters

      • mapElement: HTMLElement

        HTML element to create the map within

      Returns Map

      The OpenLayer map

    • Creates a map config based on current map state.

      Parameters

      • overrideGeocoreServiceNames: boolean | "hybrid" = true

        Indicates if geocore layer names should be kept as is or returned to defaults. Set to false after a language change to update the layer names with the new language.

      Returns TypeMapFeaturesInstance | undefined

      Map config with current map state.

    • Deletes the MapViewer, including its plugins, layers, etc. This function does not unmount the MapViewer. To completely delete a MapViewer, use cgpv.api.deleteMapViewer() which will delete the MapViewer and unmount it - for React.

      Returns Promise<void>

    • Emits a map single click event. NOTE: This Does not update the store, only emit the click

      Parameters

      Returns void

    • Asynchronously gets the map center coordinate to give a chance for the map to render before returning the value.

      Returns Promise<Coordinate>

      the map center

    • Asynchronously gets the map coordinate from pixel to give a chance for the map to render before returning the value.

      Parameters

      • pointXY: [number, number]

        The pixel coordinate to convert

      • timeoutMs: number

        The maximum time in milliseconds to wait for the getCoordinateFromPixel to return a value.

      Returns Promise<Coordinate>

      The map coordinate at the given pixel location

    • Retrieves the configuration object for a specific core plugin from the map's features configuration.

      Parameters

      • pluginId: string

        The ID of the core plugin to look up.

      Returns unknown

      The configuration object for the specified plugin, or undefined if not found.

    • Returns the current display language

      Returns TypeDisplayLanguage

      The display language

    • Returns the current display theme

      Returns TypeDisplayTheme

      The display theme

    • Gets geolocator search area

      Returns { bbox?: Extent; coords: Coordinate } | undefined

      The geolocator search area with coordinates and optional bounding box

    • Gets the i18nInstance for localization.

      Returns i18n

      The i18n instance

    • Converts a map scale denominator (1:X) into the corresponding OpenLayers resolution. Resolution is computed using: resolution = scale / (metersPerUnit * inchesPerMeter * dpi)

      Parameters

      • targetScale: number | undefined

        The scale denominator (e.g., 50000000 for 1:50,000,000). Optional; returns undefined if not provided.

      • dpiValue: number = MapViewer.DEFAULT_DPI

        Dots per inch to use for conversion. Defaults to MapViewer.DEFAULT_DPI (usually 96 or 90.714 depending on standard).

      Returns number | undefined

      The map resolution in map units per pixel, or undefined if targetScale is not provided.

    • Gets map scale for Web Mercator or Lambert Conformal Conic projections.

      Returns number | undefined

      The map scale (e.g. 50000 for 1:50,000)

    • Converts a zoom level to a map scale.

      Parameters

      • zoom: number

        The desired zoom (e.g. 50000 for 1:50,000)

      Returns number | undefined

      The closest scale for the given zoom number

    • Asynchronously gets the map size to give a chance for the map to render before returning the value.

      Returns Promise<Size>

      The map size

    • Returns the map current state information

      Returns TypeMapState

      The map state

    • Converts a map scale denominator (1:X) into the corresponding OpenLayers zoom level. Uses getMapResolutionFromScale internally and then computes the zoom for that resolution.

      Parameters

      • targetScale: number | undefined

        The scale denominator (e.g., 50000000 for 1:50,000,000). Optional; returns undefined if not provided.

      • dpiValue: number = MapViewer.DEFAULT_DPI

        Dots per inch to use for conversion. Defaults to MapViewer.DEFAULT_DPI.

      Returns number | undefined

      The OpenLayers zoom level corresponding to the scale, or undefined if targetScale is not provided.

    • Get north arrow bearing. Angle use to rotate north arrow for non Web Mercator projection https://www.movable-type.co.uk/scripts/latlong.html

      Returns string

      the arrow angle

    • Gets if north pole is visible. This is not a perfect solution and is more a work around

      Returns Promise<boolean>

      true if visible, false otherwise

    • Asynchronously attempts to get a plugin by its id.

      Parameters

      • pluginId: string

        The plugin id

      Returns AbstractPlugin

      The plugin

    • Asynchronously attempts to get a plugin by its id.

      Parameters

      • pluginId: string

        The plugin id

      Returns Promise<AbstractPlugin>

      The plugin

    • Gets the map projection

      Returns Projection

      The map projection

    • Gets the map viewSettings

      Returns View

      the map viewSettings

    • Initializes drawing interactions on the given vector source

      Parameters

      • geomGroupKey: string

        The geometry group key in which to hold the geometries

      • type: string

        The type of geometry to draw (Polygon, LineString, Circle, etc)

      • style: TypeFeatureStyle
      • OptionalgeometryFunction: GeometryFunction

      Returns Draw

    • Initializes extent interactions

      Returns Extent

    • Initializes map, layer class and geometries. This function must be called once the Map is rendered

      Returns Promise<void>

    • Initializes modifying interactions on the given vector source

      Parameters

      • geomGroupKey: string

        The geometry group key in which to hold the geometries

      • Optionalstyle: TypeFeatureStyle
      • OptionalinsertVertexCondition: Condition
      • OptionalpixelTolerance: number

      Returns Modify

    • Initializes selection interactions

      Returns Select

    • Initializes snapping interactions on the given vector source

      Parameters

      • geomGroupKey: string

        The geometry group key in which to hold the geometries

      Returns Snap

    • Initializes transform interactions for feature manipulation

      Parameters

      • Optionaloptions: Partial<TransformOptions>

        Options for the transform interaction

      Returns Transform

    • Initializes translation interactions

      Returns Translate

    • Initializes translation interactions without requireing the extra selection click. Note: This will limit translation interactions to one feature at a time.

      Returns Translate

    • Unregisters a map change size event callback.

      Parameters

      Returns void

    • Unregisters a component added event callback.

      Parameters

      Returns void

    • Unregisters a component removed event callback.

      Parameters

      Returns void

    • Unregisters a map init event callback.

      Parameters

      • callback: MapInitDelegate

        The callback to stop being called whenever the event is emitted

      Returns void

    • Unregisters a component removed event callback.

      Parameters

      Returns void

    • Unregisters a map layers loaded event callback.

      Parameters

      Returns void

    • Unregisters a map layers processed event callback.

      Parameters

      Returns void

    • Unregisters a map move end event callback.

      Parameters

      • callback: MapMoveEndDelegate

        The callback to stop being called whenever the event is emitted

      Returns void

    • Unregisters a map pointer move event callback.

      Parameters

      Returns void

    • Unregisters a map pointer stop event callback.

      Parameters

      Returns void

    • Unregisters a map change size event callback.

      Parameters

      Returns void

    • Unregisters a map ready event callback.

      Parameters

      • callback: MapReadyDelegate

        The callback to stop being called whenever the event is emitted

      Returns void

    • Unregisters a map rotation event callback.

      Parameters

      Returns void

    • Unregisters a map single click end event callback.

      Parameters

      Returns void

    • Unregisters a map zoom end event callback.

      Parameters

      • callback: MapZoomEndDelegate

        The callback to stop being called whenever the event is emitted

      Returns void

    • Registers a map change size event callback.

      Parameters

      Returns void

    • Registers a component added event callback.

      Parameters

      Returns void

    • Registers a component removed event callback.

      Parameters

      Returns void

    • Registers a map init event callback.

      Parameters

      • callback: MapInitDelegate

        The callback to be executed whenever the event is emitted

      Returns void

    • Registers a component removed event callback.

      Parameters

      Returns void

    • Registers a map layers loaded event callback.

      Parameters

      Returns void

    • Registers a map layers processed event callback.

      Parameters

      Returns void

    • Registers a map move end event callback.

      Parameters

      Returns void

    • Registers a map pointer move event callback.

      Parameters

      Returns void

    • Registers a map pointer stop event callback.

      Parameters

      Returns void

    • Registers a map projection change event callback.

      Parameters

      Returns void

    • Registers a map ready event callback.

      Parameters

      • callback: MapReadyDelegate

        The callback to be executed whenever the event is emitted

      Returns void

    • Registers a map rotation event callback.

      Parameters

      Returns void

    • Registers a map single click event callback.

      Parameters

      Returns void

    • Registers a map zoom end event callback.

      Parameters

      Returns void

    • Register handlers on pointer move and map single click

      Parameters

      • map: Map

        Map to register events on

      Returns void

    • Remove an existing custom component from the map

      Parameters

      • mapComponentId: string

        The id of the component to remove

      Returns void

    • Searches through a map config and replaces any matching layer names with their provided partner.

      Parameters

      • namePairs: string[][]

        The array of name pairs. Presumably one english and one french name in each pair.

      • OptionalmapConfig: TypeMapFeaturesConfig

        The config to modify, or one created using the current map state if not provided.

      • removeUnlisted: boolean = false

        Whether or not names not provided should be removed from config.

      Returns TypeMapFeaturesInstance | undefined

      Map config with updated names.

    • Rotates the view to align it at the given degrees

      Parameters

      • degree: number

        The degrees to rotate the map to

      Returns void

    • Sets the map center.

      Parameters

      Returns void

    • Sets the timezone used to display date values for this map. This affects how parsed date instants are converted and presented in the UI, without modifying the underlying stored values.

      Parameters

      • displayDateTimezone: string

        The IANA timezone identifier to use for display.

      Returns void

      If the time zone is not a valid or supported IANA identifier.

    • Set map extent.

      Parameters

      • extent: Extent

        New extent to zoom to.

      Returns Promise<void>

      A promise that resolves when the zoom operation completes.

    • set fullscreen / exit fullscreen

      Parameters

      • status: boolean

        Toggle fullscreen or exit fullscreen status

      • element: TypeHTMLElement | undefined

        The element to toggle fullscreen on

      Returns void

    • Update nav bar home button view settings.

      Parameters

      • view: TypeMapViewSettings

        The new view settings.

      Returns void

    • Set map to either dynamic or static

      Parameters

      • interaction: TypeInteraction

        Map interaction

      Returns void

    • Set the display language of the map

      Parameters

      • displayLanguage: TypeDisplayLanguage

        The language to use (en, fr)

      • OptionalreloadLayers: boolean

        Optional flag to ask viewer to reload layers with the new localize language

      Returns Promise<void>

    • Set the map zoom level.

      Parameters

      • zoom: number

        New zoom level

      Returns Promise<void>

      A promise that resolves when the zoom operation completes.

    • Set the maximum extent of the map.

      Parameters

      • extent: Extent

        New extent to use.

      Returns void

    • Set the maximum map zoom level.

      Parameters

      • zoom: number

        New maximum zoom level

      Returns void

    • Set the minimum map zoom level.

      Parameters

      • zoom: number

        New minimum zoom level

      Returns void

    • Set the display projection of the map

      Parameters

      • projectionCode: TypeValidMapProjectionCodes

        The projection code (3978, 3857)

      Returns Promise<void>

    • Set the display theme of the map

      Parameters

      • displayTheme: TypeDisplayTheme

        The theme to use (geo.ca, light, dark)

      Returns void

    • Set the map viewSettings (coordinate values in lon/lat)

      Parameters

      • mapView: TypeViewSettings

        Map viewSettings object

      Returns void

    • Simulate a map click and return promises of store update and ui update.

      Parameters

      • lonlat: Coordinate

        The lonlat coordinates to simulate.

      Returns SimulatedMapClick

    • Unregister handlers on pointer move and map single click

      Parameters

      • map: Map

        Map to unregister events on

      Returns void

    • Update the size of the icon image list based on styles.

      Parameters

      Returns void

    • Waits until all GeoView layers reach the specified status before resolving the promise. This function repeatedly checks whether all layers have reached the given layerStatus.

      Parameters

      • layerStatus: TypeLayerStatus

        The desired status to wait for (e.g., 'loaded', 'processed').

      Returns Promise<number>

      A promise that resolves with the number of layers that have reached the specified status.

    • Waits for the map layers loaded event to be emitted.

      Returns Promise<number>

      A promise that resolves with the number of layers that have reached the specified status.

    • Waits for the rendercomplete event to be triggered

      Returns Promise<void>

      Promise resolved when map render is complete

    • Zoom to the specified extent.

      Parameters

      • extent: Extent

        The extent to zoom to.

      • Optionaloptions: FitOptions

        The options to configure the zoomToExtent (default: { padding: [100, 100, 100, 100], maxZoom: 11 }).

      Returns Promise<void>

      A promise that resolves when the zoom operation completes.

    • Zoom to the initial extent defined in the map configuration.

      Returns Promise<void>

      A promise that resolves when the zoom operation completes.

    • Zoom to specified extent or coordinate provided in lonlat.

      Parameters

      • extent: Extent | Coordinate

        The extent or coordinate to zoom to.

      • Optionaloptions: FitOptions

        The options to configure the zoomToExtent (default: { padding: [100, 100, 100, 100], maxZoom: 11 }).

      Returns Promise<void>

      A promise that resolves when the zoom operation completes.