Skip to content

Convert ESRI styles to OpenLayers styles

Notifications You must be signed in to change notification settings

zakariah1/ol-esri-style

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

60 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Convert ESRI styles to OpenLayers styles

Info

This module can convert ESRI style definition to OpenLayers style function. ESRI style definition must be in JSON format - https://developers.arcgis.com/documentation/common-data-types/renderer-objects.htm

Getting started

Import as ES6 module:

import { createStyleFunctionFromUrl, setMapProjection } from 'ol-esri-style';

// create a new vector layer
const vector = new VectorLayer({
  ...
});

// This is need for labeling features. Visible resolutions for the labels are calculated using map projection units.
setMapProjection(map.getView().getProjection());

// set layer style
createStyleFunctionFromUrl('arcgis_server_layer_url').then(styleFunction => {
  vector.setStyle(styleFunction);
});

Example

To check the example stored in /test directory run:

npm run test

The example loads data from https://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Petroleum/KSFields/FeatureServer/0 and the style definition is from https://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Petroleum/KSFields/FeatureServer/0?f=json.

Dependencies

License

The MIT License (MIT).

About

Convert ESRI styles to OpenLayers styles

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 97.7%
  • HTML 2.3%