Skip to content

Commit

Permalink
Merge pull request #260 from jonataswalker/remove-browser-field
Browse files Browse the repository at this point in the history
Remove `browser`  field from package.json
  • Loading branch information
jonataswalker authored Mar 13, 2023
2 parents c2fb094 + a2d2f1a commit 20eb729
Show file tree
Hide file tree
Showing 10 changed files with 158 additions and 4,627 deletions.
23 changes: 12 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ A `contextmenu` extension for [OpenLayers](http://openlayers.org/). **Requires**

## Demo

[JSFiddle](https://jsfiddle.net/jonataswalker/ooxs1w5d/).
[JSFiddle](https://jsfiddle.net/jonataswalker/ooxs1w5d/)
[CodeSandbox](https://codesandbox.io/s/openlayers-custom-context-menu-5s99kb?file=/src/index.js)

## How to use it?

Expand Down Expand Up @@ -54,7 +55,7 @@ Download [latest release](https://github.com/jonataswalker/ol-contextmenu/releas
##### Instantiate with some options and add the Control

```javascript
var contextmenu = new ContextMenu({
const contextmenu = new ContextMenu({
width: 170,
defaultItems: true, // defaultItems are (for now) Zoom In/Zoom Out
items: [
Expand All @@ -81,7 +82,7 @@ map.addControl(contextmenu);
If you provide `items {Array}` a submenu will be created as a child of the current item.

```javascript
var all_items = [
const all_items = [
{
text: 'Some Actions',
items: [
Expand All @@ -108,18 +109,18 @@ var all_items = [
##### Would you like to propagate custom data to the callback handler?

```javascript
var removeMarker = function (obj) {
const removeMarker = function (obj) {
vectorLayer.getSource().removeFeature(obj.data.marker);
};
var removeMarkerItem = {
const removeMarkerItem = {
text: 'Remove this Marker',
icon: 'img/marker.png',
callback: removeMarker,
};

var restore = false;
let restore = false;
contextmenu.on('open', function (evt) {
var feature = map.forEachFeatureAtPixel(evt.pixel, function (ft, l) {
const feature = map.forEachFeatureAtPixel(evt.pixel, function (ft, l) {
return ft;
});
if (feature) {
Expand Down Expand Up @@ -168,10 +169,10 @@ Add items to the menu. This pushes each item in the provided array to the end of
Example:

```js
var contextmenu = new ContextMenu();
const contextmenu = new ContextMenu();
map.addControl(contextmenu);

var add_later = [
const add_later = [
'-', // this is a separator
{
text: 'Add a Marker',
Expand Down Expand Up @@ -216,7 +217,7 @@ Update menu's position.

```javascript
contextmenu.on('beforeopen', function (evt) {
var feature = map.forEachFeatureAtPixel(evt.pixel, function (ft, l) {
const feature = map.forEachFeatureAtPixel(evt.pixel, function (ft, l) {
return ft;
});

Expand All @@ -233,7 +234,7 @@ contextmenu.on('beforeopen', function (evt) {

```javascript
contextmenu.on('open', function (evt) {
var feature = map.forEachFeatureAtPixel(evt.pixel, function (ft, l) {
const feature = map.forEachFeatureAtPixel(evt.pixel, function (ft, l) {
return ft;
});

Expand Down
Loading

0 comments on commit 20eb729

Please sign in to comment.