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

    Class MapViewer

    Class used to manage created maps.

    Index
    addComponent clickMarkerIconShow convertCoordinateFromMapProjToProj convertCoordinateFromProjToMapProj convertCoordinateLonLatToMapProj convertCoordinateMapProjToLonLat convertExtentFromMapProjToProj convertExtentFromProjToMapProj convertExtentLonLatToMapProj convertExtentMapProjToLonLat createMap createMapConfigFromMapState delete getClickMarkerOverlay getCorePackageConfig getDisplayLanguage getDisplayTheme getGeolocatorSearchArea getI18nInstance getMapLayerOrderPaths getMapResolutionFromScale getMapScale getMapScaleFromZoom getMapState getNorthArrowAngle getNorthPoleMarkerOverlay getNorthPoleVisibility getPlugin getProjection getProjectionEPSG getProjectionNumber getView initDrawInteractions initExtentInteractions initMap initMapControls initModifyInteractions initSelectInteractions initSnapInteractions initTransformInteractions initTranslateInteractions initTranslateOneFeatureInteractions offMapComponentAdded offMapComponentRemoved offMapInit offMapInteractionChanged offMapLanguageChanged offMapLayersLoaded offMapLayersProcessed offMapMouseEnter offMapMouseLeave offMapMoveEnd offMapPointerMove offMapPointerStop offMapProjectionChanged offMapProjectionChangeStarted offMapReady offMapResolutionChanged offMapRotation offMapSingleClick offMapSizeChanged offMarkerIconShowed onceMapMoveEnd onceMapReady onMapComponentAdded onMapComponentRemoved onMapInit onMapInteractionChanged onMapLanguageChanged onMapLayersLoaded onMapLayersProcessed onMapMouseEnter onMapMouseLeave onMapMoveEnd onMapPointerMove onMapPointerStop onMapProjectionChanged onMapProjectionChangeStarted onMapReady onMapResolutionChanged onMapRotation onMapSingleClick onMapSizeChanged onMarkerIconShowed registerMapPointerHandlers removeComponent replaceMapConfigLayerNames rotate setCenter setDisplayDateTimezone setFullscreen setHomeButtonView setInteraction setLanguage setMapZoomLevel setMaxZoomLevel setMinZoomLevel setProjection setTheme setView simulateMapClick unregisterMapPointerHandlers updateIconImageCache waitForMapReady waitForMoveEnd waitForRender zoomMap zoomToExtent zoomToInitialExtent zoomToLonLatExtentOrCoordinate computeEffectiveLayerScales getScaleInfoFromDomElement
    appBarApi: AppBarApi

    Used to access button bar API to create buttons and button panels on the app-bar

    basemap: BasemapApi

    Used to access basemap API functions

    controllers: ControllerRegistry

    The controller registry owning all framework-level controllers.

    Try not to use this accessor, as it creates a backwards dependency from the domain to the controllers. It is here for legacy reasons, but should be removed in the future.

    featureHighlight: FeatureHighlight

    Used to access feature highlight API functions

    footerBarApi: FooterBarApi

    Used to access the footer bar API to create buttons and footer panels on the footer-bar

    geometry: GeometryApi

    Used to access geometry API to create and manage geometries

    iconImageCacheSize: number = 1

    Max number of icons cached

    layer: LayerApi

    Used to access layers functions

    map: Map

    The OpenLayers map instance

    mapFeaturesConfig: TypeMapFeaturesConfig

    Map features configuration properties

    mapId: string

    The id of the map

    modal: ModalApi

    Modals creation

    navBarApi: NavBarApi

    Used to access button bar API to create buttons and button panels on the nav-bar

    notifications: Notifications

    Used to attach the notification class

    overviewRoot: Root | undefined

    The overview map React root

    plugins: PluginsContainer = {}

    Plugins attached to the map

    stateApi: StateApi

    Used to manage states

    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

    EFFECTIVE_SCALE_VISIBILITY_BUFFER: 0.11

    Buffer applied to effective scale calculations to account for visibility thresholds

    • Add a new custom component to the map.

      Parameters

      • mapComponentId: string

        An id to the new component

      • component: any

        The component to add

      Returns void

    • Transforms extent from map projection to given projection. If the projections 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 given 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

        Optional - 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.

      • includeFeatureInfo: boolean = false

        Optional - Indicates if feature info should be included in the config for each layer.

      Returns TypeMapFeaturesInstance | undefined

      Map config with current map state, or undefined if unavailable

    • 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>

      A promise that resolves when the deletion is complete

    • 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

    • 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), or undefined if meters per unit is unavailable

    • 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, rounded to the nearest unit, or undefined if meters per unit is unavailable

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

      This approach is rotation-agnostic — it works regardless of the map's current rotation angle.

      Returns boolean

      True if the north pole is visible in the viewport, false otherwise

    • Initializes drawing interactions on the given vector source.

      Parameters

      • geomGroupKey: string

        The geometry group key in which to hold the geometries

      • type: Type

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

      • style: TypeFeatureStyle

        The styles for the drawing

      • OptionalgeometryFunction: GeometryFunction

        Optional geometry function for custom drawing behavior

      Returns Draw

      The draw interaction

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

      Returns Promise<void>

      A promise that resolves when the map initialization is complete

    • Initializes modifying interactions on the given vector source.

      Parameters

      • geomGroupKey: string

        The geometry group key in which to hold the geometries

      • Optionalstyle: TypeFeatureStyle

        Optional styles for the modification

      • OptionalinsertVertexCondition: Condition

        Optional condition for inserting vertices

      • OptionalpixelTolerance: number

        Optional pixel tolerance for modification

      Returns Modify

      The modify interaction

    • 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

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

      • removeUnlisted: boolean = false

        Optional - Whether or not names not provided should be removed from config

      Returns TypeMapFeaturesInstance | undefined

      Map config with updated names, or undefined if no config is available

    • 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

      When the time zone is not a valid or supported IANA identifier

    • 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>

      A promise that resolves when the language change is complete

    • Set the display projection of the map.

      Parameters

      • projectionNumber: TypeValidMapProjectionCodes

        The projection code (3978, 3857)

      Returns boolean

      True if the projection was changed, false if the projection code is unsupported

    • Waits for the next rendercomplete event to be emitted.

      Forces a synchronous frame via map.renderSync() so rendercomplete is guaranteed to fire, even when the map is idle. Without this, waiting on rendercomplete for an idle map hangs forever because OL does not schedule a frame unless something invalidates the view.

      Returns Promise<void>

      A promise that resolves when the map render is complete

    • Animates the map to the specified zoom level.

      The store is updated automatically via the MapViewer move-end event.

      Parameters

      • zoom: number

        The target zoom level

      • useAnimation: boolean = true

        Indicates if a zoom animation should be used, default: true

      • duration: number = OL_ZOOM_DURATION

        Optional animation duration in ms

      Returns Promise<void>

      A promise that resolves when the zoom animation is complete

    • Zooms to the specified extent.

      Parameters

      • extent: Extent

        The extent to zoom to

      • useAnimation: boolean = true

        Indicates if a zoom animation should be used, default: true

      • options: FitOptions = DEFAULT_OL_FITOPTIONS

        The options to configure the zoomToExtent (default: { padding: [100, 100, 100, 100], maxZoom: 13, duration: 500 })

      Returns Promise<void>

      A promise that resolves when the zoom animation is complete

      When the extent is invalid

    • Returns to initial view state of the map using config.

      Parameters

      • useAnimation: boolean = true

        Indicates if a zoom animation should be used, default: true

      Returns Promise<void>

      A promise that resolves when the zoom animation is complete

    • Zoom to specified extent or coordinate provided in lonlat.

      Parameters

      • extent: Extent | Coordinate

        The extent or coordinate to zoom to

      • useAnimation: boolean = true

        Indicates if a zoom animation should be used, default: true

      • Optionaloptions: FitOptions

        Optional 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

    • Computes the effective minimum and maximum scales for a layer from its configuration and initial settings.

      Combines scales from configuration and initial settings zoom levels, selecting the most restrictive value.

      Parameters

      • mapViewer: MapViewer

        The map viewer used for zoom-to-scale conversions

      • layerConfig: ConfigBaseClass

        The layer configuration to compute scales from

      Returns EffectiveLayerScales

      Object with effective scale thresholds and buffered visibility limits