1.5.0 • Published 4 months ago

@delivus/react-open-layers v1.5.0

Weekly downloads
-
License
MIT
Repository
github
Last release
4 months ago

React openlayers wrapper

A wrapper library designed to create openlayers map in an easy and customizablew way.

Installation

Install with npm

  npm install @delivus/react-open-layers

Install with yarn

  yarn add @delivus/react-open-layers

Preferred node version: 16

Documentation

Full usage

import {
  ClusterLayer,
  Control,
  OpenLayers,
  Overlay,
} from "@delivus/react-open-layers";
  <OpenLayers
   interactionOptions={{ pinchZoom: true }}
   className={"shipping-map"}
   onMouseOverFeatures={handleMouseOverCluster}
   onMouseOutFeatures={handleMouseOutCluster}
   onClickFeatures={handleClickCluster}>
   
   <Control
    id={"right-control"}
    className={"map-floating-cntr map-right-floating shipping-float"}>
      {children}
    </Control>
    <Overlay
     id={"shipping-tooltip"}
     className={"tooltip"}
     position={hoveredShippingTooltip?.position}>
    <ShippingsTooltip shippings={hoveredShippingTooltip?.shippings} />
    </Overlay>
    <ClusterLayer
      clusterStyle={styleShippingCluster}
      features={renderMarkers()}
      />
    </OpenLayers>

Examples

Basic example

Marker example

Cluster example

Tooltip example

Available Loaders, PropTypes, and Default Values

Optional default props for all Map components:

  interactionOptions: DefaultsOptions;
  layers: BaseLayer[] | Collection<BaseLayer> | LayerGroup | undefined;
  showZoom: boolean;
  zoomInStyle: zoomStyleProps;
  zoomOutStyle: zoomStyleProps;
  viewOptions: ViewOptions;
  initialCenter: number[];
  className: string;
  children: ReactNode | ReactNode[];
  fitOptions: FitOptions;
  enableFitWhenClick: boolean;
  onClickMap: () => void;
  onClick:(feature: FeatureLike[], event:  ol.MapBrowserEvent<any>) => void;
  onLoadStart: (event:  ol.MapEvent)=>void;
  onLoadEnd: (event:  ol.MapEvent)=>void;
  onMoveStart: (event:  ol.MapEvent)=>void;
  onMoveEnd: (event:  ol.MapEvent)=>void;
  onPointerDrag: (event:  ol.MapBrowserEvent<any>)=>void;
  onPointerMove: (event:  ol.MapBrowserEvent<any>)=>void;
  onPostRender: (event:   ol.MapEvent)=>void;
  onPostCompose: (event:  any)=>void;
  onPreCompose: (event:  any)=>void;
  onRenderComplete: (event:  any)=>void;
  onDoubleClick:(feature: FeatureLike[], event:  ol.MapBrowserEvent<any>) => void;
  onMouseOverFeatures: (feature: Feature<Geometry>[], event: Event) => void;
  onMouseOutFeatures: (feature?: Feature<Geometry>[]) => void;
  onClickFeatures: (feature: Feature<Geometry>[], event: Event) => void;
  moveTolerance: number;
  maxTilesLoading: number;

interactionOptions

interactionOptions prop is a set of interactions included in maps by default

for more information : interactionOptions

layers

The layers prop allows user to add layers for the map as an array collection similar to openlayers prop for layers.

For example : layers: [ raster, vector ],

showZoom

The showZoom props is a boolean value and enable / disable zoom icons on the openlayers map

zoomInStyle & zoomOutStyle

Both zoomInStyle & zoomOutStyle props allows styling for zoomIn and zoomOut buttons that are displayed on the map view

Accepted styling props are:

 width: string;
 height: string;
 backgroundColor: string;
 bottom: string;
 top: string;
 left: string;
 right: string;

viewOptions

viewOptions prop is a set of view properties included in maps by default

for more information : viewOptions

initialCenter

The initialCenter prop allows user to set center point on map

The default center point for map is set as [126.83, 37.57] (South Korea)

className

className prop allows styling of map component

children

children prop allows to mount react node component as child

fitOptions

fitOptions prop allows to set view component of ol map view fitOptions

enableFitWhenClick

enableFitWhenClick prop enables singleClick function on features populated on the map

onClickMap

onClickMap prop returns a listener event object whenever map is clicked

onClick

onClick prop returns a single click event listener ol browser map event object whenever features in the map are clicked and feature data

onLoadStart

onLoadStart event is triggered when loading of additional map data (tiles, images, features) starts.

onLoadEnd

onLoadEnd event is triggered when loading of additional map data has completed.

onMoveStart

onMoveStart event is triggered when the map starts moving.

onMoveEnd

onMoveEnd event is triggered after the map is moved.

onPointerDrag

onPointerDrag event is triggered when a pointer is dragged.

onPointerMove

onPointerMove event is triggered when a pointer is moved. Note that on touch devices this is triggered when the map is panned, so is not the same as mousemove.

onPostRender

onPostRender event is triggered after a map frame is rendered.

onPostCompose

onPostCompose event is triggered after layers are composed. When dispatched by the map, the event object will not have a context set. When dispatched by a layer, the event object will have a context set. Only WebGL layers currently dispatch this event.

onPreCompose

onPreCompose event is triggered before layers are composed. When dispatched by the map, the event object will not have a context set. When dispatched by a layer, the event object will have a context set. Only WebGL layers currently dispatch this event.

onRenderComplete

onRenderComplete event is triggered when rendering is complete, i.e. all sources and tiles have finished loading for the current viewport, and all tiles are faded in. The event object will not have a context set.

onDoubleClick

onDoubleClick event is a true double click, with no dragging.

onMouseOverFeatures

onMouseOverFeatures event is triggered when a pointer is moved over the feature in the ol map view.

onMouseOutFeatures

onMouseOutFeatures event is triggered when a pointer is moved outside the feature in the ol map view.

onClickFeatures

onClickFeatures enables feature click on ol layer for more event object description

moveTolerance

moveTolerance prop sets the minimum distance in pixels the cursor must move to be detected as a map move event instead of a click. Increasing this value can make it easier to click on the map. Default value is 1

maxTilesLoading

maxTilesLoading props sets the maximum number tiles to load simultaneously. Default value is 16

License

MIT License GPLv3 License AGPL License

Authors

1.5.0

4 months ago

2.0.8

4 months ago

2.0.5

4 months ago

2.0.7

4 months ago

2.0.6

4 months ago

2.0.3

4 months ago

2.0.4

4 months ago

2.0.2

4 months ago

2.0.1

4 months ago

1.4.0

4 months ago

2.0.0

4 months ago

1.3.0

4 months ago

1.2.3

4 months ago

1.2.2

4 months ago

1.2.0

5 months ago

1.0.9

5 months ago

1.1.1

5 months ago

1.1.0

5 months ago

1.0.8

6 months ago

1.0.7

6 months ago

1.0.6

8 months ago

1.0.5

8 months ago

1.0.4

8 months ago

1.0.3

9 months ago

1.0.2

9 months ago

1.0.1

9 months ago

0.3.16

9 months ago

0.3.14

9 months ago

0.3.13

9 months ago

1.0.0

9 months ago

0.3.12

9 months ago

0.3.7

9 months ago

0.3.6

9 months ago

0.3.5

9 months ago

0.3.4

9 months ago

0.3.3

9 months ago

0.3.2

9 months ago

0.3.1

9 months ago

0.3.0

9 months ago

0.2.57

9 months ago

0.2.56

9 months ago

0.2.55

9 months ago

0.2.54

9 months ago

0.2.53

9 months ago

0.2.52

9 months ago

0.2.51

9 months ago

0.2.50

9 months ago

0.2.49

9 months ago

0.2.48

9 months ago

0.2.47

9 months ago

0.2.46

9 months ago

0.2.45

9 months ago

0.2.44

9 months ago

0.2.43

9 months ago

0.2.42

9 months ago

0.2.41

9 months ago

0.2.40

9 months ago

0.2.39

10 months ago

0.2.38

10 months ago

0.2.37

10 months ago

0.2.36

10 months ago

0.2.35

10 months ago

0.2.34

10 months ago

0.2.33

10 months ago

0.2.32

10 months ago

0.2.31

10 months ago

0.2.30

10 months ago

0.2.29

10 months ago

0.2.28

10 months ago

0.2.27

10 months ago

0.2.26

10 months ago

0.2.25

10 months ago

0.2.24

10 months ago

0.2.23

10 months ago

0.2.22

10 months ago

0.2.21

10 months ago

0.2.20

10 months ago

0.2.19

10 months ago

0.2.18

10 months ago

0.2.17

10 months ago

0.2.16

10 months ago

0.2.15

10 months ago

0.2.14

10 months ago

0.2.13

10 months ago

0.2.12

10 months ago

0.2.11

10 months ago

0.2.10

10 months ago

0.2.9

10 months ago

0.2.8

10 months ago

0.2.7

10 months ago

0.2.6

10 months ago

0.2.5

10 months ago

0.2.4

10 months ago

0.2.3

10 months ago

0.2.2

10 months ago

0.2.1

10 months ago

0.2.0

10 months ago

0.1.9

10 months ago

0.1.8

10 months ago

0.1.7

11 months ago

0.1.6

11 months ago

0.1.3

11 months ago

0.1.2

11 months ago

0.1.1

11 months ago