Skip to content

Commit

Permalink
rename event
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanocudini committed May 25, 2018
1 parent 8356d46 commit be14dd8
Show file tree
Hide file tree
Showing 7 changed files with 108 additions and 51 deletions.
30 changes: 30 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,36 @@ Licensed under the [MIT](https://opensource.org/licenses/MIT)
[Github](https://github.com/stefanocudini/leaflet-geojson-selector)
[NPM](https://npmjs.org/package/leaflet-geojson-selector)


# Options
| Option | Default | Description |
| --------------------- | ----------------- | ----------------------------------------- |
| collapsed | false | collapse panel list |
| position | 'bottomleft' | position of panel list |
| listLabel | 'properties.name' | GeoJSON property to generate items list |
| listSortBy | 'properties.name' | property to sort items, default is listLabel |
| listItemBuild | null | function list item builder |
| activeListFromLayer | true | highlight of list item on layer hover |
| zoomToLayer | false | |
| listOnlyVisibleLayers | false | show only items visible in map canvas |
| multiple | false | active multiple selection |
| style | {} | style for GeoJSON features |
| activeClass | 'active' | css class name for active list items |
| activeStyle | | style for Active GeoJSON features |
| selectClass | 'selected' | |
| selectStyle | {} | style for Selected GeoJSON features |

# Events
| Event | Data | Description |
| ---------------------- | ---------------------- | ----------------------------------------- |
| 'selector:change' | {selected, layers} | fired after checked item in list, selected is true if any layer is selected |

# Methods
| Method | Arguments | Description |
| ------------- | -------------- | ---------------------------- |
| reload() | layer | search text by external code |


#Build

Since Version 1.4.7 this plugin support [Grunt](http://gruntjs.com/) for building process.
Expand Down
2 changes: 1 addition & 1 deletion dist/leaflet-geojson-selector.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions dist/leaflet-geojson-selector.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/leaflet-geojson-selector.src.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Leaflet GeoJSON Selector v0.4.1 - 2018-05-09
* Leaflet GeoJSON Selector v0.4.2 - 2018-05-25
*
* Copyright 2018 Stefano Cudini
* [email protected]
Expand Down
62 changes: 38 additions & 24 deletions dist/leaflet-geojson-selector.src.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Leaflet GeoJSON Selector v0.4.1 - 2018-05-09
* Leaflet GeoJSON Selector v0.4.2 - 2018-05-25
*
* Copyright 2018 Stefano Cudini
* [email protected]
Expand All @@ -14,20 +14,34 @@
* [email protected]:stefanocudini/leaflet-geojson-selector.git
*
*/
/*
Name Data passed Description
(function() {
Managed Events:
selector:change {selected, layers} fired after checked item in list, selected is true if any layer is selected
Public methods:
reload() {layer} load or reload a geojson layer
*/
(function (factory) {
if(typeof define === 'function' && define.amd) {
//AMD
define(['leaflet'], factory);
} else if(typeof module !== 'undefined') {
// Node/CommonJS
module.exports = factory(require('leaflet'));
} else {
// Browser globals
if(typeof window.L === 'undefined')
throw 'Leaflet must be loaded first';
factory(window.L);
}
})(function (L) {

L.Control.GeoJSONSelector = L.Control.extend({
//
// Name Data passed Description
//
//Managed Events:
// change {layers} fired after checked item in list
//
//Public methods:
// TODO...
//
includes: L.Mixin.Events,

includes: L.version[0]==='1' ? L.Evented.prototype : L.Mixin.Events,

options: {
collapsed: false, //collapse panel list
Expand All @@ -37,7 +51,8 @@ L.Control.GeoJSONSelector = L.Control.extend({
listSortBy: null, //GeoJSON property to sort items list, default listLabel
listItemBuild: null, //function list item builder

activeListFromLayer: true, //enable activation of list item from layer
activeListFromLayer: true, //highlight of list item on layer hover
//TODO activeLayerFromList: true, //highlight of layer on list item hover
zoomToLayer: false,

listOnlyVisibleLayers: false, //show list of item of layers visible in map canvas
Expand Down Expand Up @@ -205,8 +220,8 @@ L.Control.GeoJSONSelector = L.Control.extend({
that._selectItem(item, input.checked);
that._selectLayer(layer, input.checked);

that.fire('change', {
selected: input.checked,
that.fire('selector:change', {
selected: input.checked,
layers: [layer]
});

Expand Down Expand Up @@ -387,13 +402,13 @@ L.Control.GeoJSONSelector = L.Control.extend({
paddingBottomRight: null
};

/*var ne = this._map.containerPointToLatLng( L.point(psize.x, 0) ),
sw = this._map.containerPointToLatLng( L.point(msize.x, psize.y) ),
bb = L.latLngBounds(sw, ne);
*/
/*L.rectangle(bb).addTo(this._map);
L.marker(bb.getCenter()).addTo(this._map);
*/
/*var ne = this._map.containerPointToLatLng( L.point(psize.x, 0) ),
sw = this._map.containerPointToLatLng( L.point(msize.x, psize.y) ),
bb = L.latLngBounds(sw, ne);
*/
/*L.rectangle(bb).addTo(this._map);
L.marker(bb.getCenter()).addTo(this._map);
*/

if (pos.indexOf('right') !== -1) {
fitOpts.paddingBottomRight = L.point(psize.x, 0);
Expand All @@ -415,5 +430,4 @@ L.control.geoJsonSelector = function (layer, options) {
return new L.Control.GeoJSONSelector(layer, options);
};


}).call(this);
});
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "leaflet-geojson-selector",
"version": "0.4.1",
"version": "0.4.2",
"description": "Leaflet Control for select GeoJSON properties in a interactive menu and map",
"repository": {
"type": "git",
Expand Down
57 changes: 35 additions & 22 deletions src/leaflet-geojson-selector.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,31 @@
/*
Name Data passed Description
(function() {
Managed Events:
selector:change {selected, layers} fired after checked item in list, selected is true if any layer is selected
Public methods:
reload() {layer} load or reload a geojson layer
*/
(function (factory) {
if(typeof define === 'function' && define.amd) {
//AMD
define(['leaflet'], factory);
} else if(typeof module !== 'undefined') {
// Node/CommonJS
module.exports = factory(require('leaflet'));
} else {
// Browser globals
if(typeof window.L === 'undefined')
throw 'Leaflet must be loaded first';
factory(window.L);
}
})(function (L) {

L.Control.GeoJSONSelector = L.Control.extend({
//
// Name Data passed Description
//
//Managed Events:
// change {layers} fired after checked item in list
//
//Public methods:
// TODO...
//
includes: L.Mixin.Events,

includes: L.version[0]==='1' ? L.Evented.prototype : L.Mixin.Events,

options: {
collapsed: false, //collapse panel list
Expand Down Expand Up @@ -190,8 +204,8 @@ L.Control.GeoJSONSelector = L.Control.extend({
that._selectItem(item, input.checked);
that._selectLayer(layer, input.checked);

that.fire('change', {
selected: input.checked,
that.fire('selector:change', {
selected: input.checked,
layers: [layer]
});

Expand Down Expand Up @@ -372,13 +386,13 @@ L.Control.GeoJSONSelector = L.Control.extend({
paddingBottomRight: null
};

/*var ne = this._map.containerPointToLatLng( L.point(psize.x, 0) ),
sw = this._map.containerPointToLatLng( L.point(msize.x, psize.y) ),
bb = L.latLngBounds(sw, ne);
*/
/*L.rectangle(bb).addTo(this._map);
L.marker(bb.getCenter()).addTo(this._map);
*/
/*var ne = this._map.containerPointToLatLng( L.point(psize.x, 0) ),
sw = this._map.containerPointToLatLng( L.point(msize.x, psize.y) ),
bb = L.latLngBounds(sw, ne);
*/
/*L.rectangle(bb).addTo(this._map);
L.marker(bb.getCenter()).addTo(this._map);
*/

if (pos.indexOf('right') !== -1) {
fitOpts.paddingBottomRight = L.point(psize.x, 0);
Expand All @@ -400,5 +414,4 @@ L.control.geoJsonSelector = function (layer, options) {
return new L.Control.GeoJSONSelector(layer, options);
};


}).call(this);
});

0 comments on commit be14dd8

Please sign in to comment.