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

    Class MapViewer

    Class used to manage created maps.

    Index

    Constructors

    Properties

    Accessors

    Methods

    addComponent clickMarkerIconShow convertCoordinateFromMapProjToProj convertCoordinateFromProjToMapProj convertCoordinateLonLatToMapProj convertCoordinateMapProjToLonLat convertExtentFromMapProjToProj convertExtentFromProjToMapProj convertExtentLonLatToMapProj convertExtentMapProjToLonLat createMap createMapConfigFromMapState delete emitMapSingleClick getCenter getClickMarkerOverlay getCoordinateFromPixel getCorePackageConfig getDisplayLanguage getDisplayTheme getGeolocatorSearchArea getI18nInstance getMapLayerOrderPaths getMapResolutionFromScale getMapScale getMapScaleFromZoom getMapSize getMapState getMapZoomFromScale getNorthArrowAngle getNorthPoleMarkerOverlay getNorthPoleVisibility getPlugin getPluginAsync getProjection getProjectionEPSG getProjectionNumber getView initDrawInteractions initExtentInteractions initMap initMapControls initModifyInteractions initSelectInteractions initSnapInteractions initTransformInteractions initTranslateInteractions initTranslateOneFeatureInteractions offMapChangeSize offMapComponentAdded offMapComponentRemoved offMapInit offMapLanguageChanged offMapLayersLoaded offMapLayersProcessed offMapMoveEnd offMapPointerMove offMapPointerStop offMapProjectionChanged offMapProjectionChangeStarted offMapReady offMapRotation offMapSingleClick offMapZoomEnd onMapChangeSize onMapComponentAdded onMapComponentRemoved onMapInit onMapLanguageChanged onMapLayersLoaded onMapLayersProcessed onMapMoveEnd onMapPointerMove onMapPointerStop onMapProjectionChanged onMapProjectionChangeStarted 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 waitForMapReady waitForRender zoomToExtent zoomToInitialExtent zoomToLonLatExtentOrCoordinate getScaleInfoFromDomElement

    Constructors

    Properties

    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

    ZOOM_LEVEL_FROM_SCALE_BUFFER: 0.21

    A zoom level buffer to guarantee that the calculations being done via the resolutions, inches per meter, dpi are more strict than not enough The value 0.21 seems rather specific, but it was the value giving us the best result during testing on layer National Forest Inventory Photo Plot Summary (6433173f-bca8-44e6-be8e-3e8a19d3c299) at zoom level 3.78 +/- 0.25 It could be increased slightly if ever we need to, but it might offer worse precision depending on various layers

    Accessors

    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

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

      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

    • Emits a map single click event.

      NOTE: This Does not update the store, only emit the click.

      Parameters

      • clickCoordinates: TypeMapMouseInfo

        The clicked coordinates to emit

      Returns void

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

      A promise that resolves with 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

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

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

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

      Returns Promise<boolean>

      A promise that resolves with true if visible, false otherwise

    • 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

        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 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 map to be ready before resolving the promise.

      This function checks if the map is already ready, and if not, it waits for the onMapReady event to be triggered.

      Returns Promise<void>

      A promise that resolves when the map is ready.

    • Zoom to the specified extent.

      Parameters

      • extent: Extent

        The extent to zoom to

      • 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

    • Zoom to specified extent or coordinate provided in lonlat.

      Parameters

      • extent: Extent | Coordinate

        The extent or coordinate to zoom to

      • 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