Skip to content

Latest commit

 

History

History
104 lines (65 loc) · 3.3 KB

DEVELOPING.md

File metadata and controls

104 lines (65 loc) · 3.3 KB

Developing

Setting up development environment

You will start by forking the OpenLayers repository.

Installing dependencies

The minimum requirements are:

  • Git
  • Node.js (version 16 and above)

The executables git and node should be in your PATH.

To install the project dependencies run

npm install

Style guidelines

We use ESLint rules to ensure a consistent coding style and catch potential bugs. ESLint and the rules used by the project are installed as part of the development dependencies in the step above – so you don't need to have any additional executables installed globally.

When you submit a pull request, the styling rules are enforced by running the npm run lint task. This happens as part of an automated workflow, so you don't need to run it yourself. However, it can be useful to run the npm run lint task before submitting a pull request so that you can fix any styling issues ahead of time.

The best way to conform with the style guidelines is to configure your editor to detect the ESLint configuration from the repository's package.json file. See the ESLint integration documentation for details on configuring your editor. If you don't already have a preferred editor that is capable of running ESLint rules, we recommend using VS Code with the ESLint plugin.

In addition to having your editor warn you when the style guidelines are not being followed, you can set things up so many of the violations are automatically fixed. This saves you from having to think about tedious things like spacing and whitespace while developing. Using the ESLint plugin for VS Code, you can add the following to your settings to automatically fix issues when you save a file:

{
  "editor.codeActionsOnSave": {
    "source.fixAll": true
  }
}

Running examples

To run the examples you first need to start the dev server:

npm run serve-examples

Then, load http://localhost:8080/ in your browser.

Running tests

To run the tests once:

npm test

To run the tests continuously during development:

npm run karma

Adding examples

Adding functionality often implies adding one or several examples. This section provides explanations related to adding examples.

The examples are located in the examples directory. Adding a new example implies creating two or three files in this directory, an .html file, a .js file, and, optionally, a .css file.

You can use simple.js and simple.html as templates for new examples.

Linking Package

The ol package is published from the build/ol folder of the openlayers repo.

After you've cloned the openlayers repo locally run the npm build-package to prepare the build then use the npm link command to connect it your project.

Below is an example of how to build and link it to sample-project.

cd openlayers
npm run build-package
cd build/ol
npm link
cd /sample-project
npm link ol

To remove the link run the following commands

cd sample-project
npm unlink --no-save ol
cd ../openlayers
npm unlink