geoview-core
    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 getI18nInstance getMapLayerOrderInfo getMapSize getMapState getNorthArrowAngle getNorthVisibility getPlugin 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 refreshLayers registerMapPointerHandlers removeComponent replaceMapConfigLayerNames rotate setCenter setExtent setFullscreen setHomeButtonView setInteraction setLanguage setMaxExtent setMaxZoomLevel setMinZoomLevel setProjection setTheme setView setZoomLevel unregisterMapPointerHandlers updateIconImageCache waitAllLayersStatus zoomToExtent zoomToLonLatExtentOrCoordinate

    Constructors

    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_STOPS: number = 25
    INIT_TIMEOUT_NORTH_VISIBILITY: number = 1000

    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

    • 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

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

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

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

    • Loops through all geoview layers and refresh their respective source. Use this function on projection change or other viewer modification which may affect rendering.

      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.

    • Set the display language of the map

      Parameters

      • displayLanguage: TypeDisplayLanguage

        The language to use (en, fr)

      • OptionalreloadLayers: boolean

      Returns Promise<void>

    • Set the display projection of the map

      Parameters

      • projectionCode: TypeValidMapProjectionCodes

        The projection code (3978, 3857)

      Returns Promise<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.

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