You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
_Pronounced leaflet-G.L.-Ify, or leaflet-glify, or L.-G.L.-Ify, or L-glify, or elglify_
@@ -8,44 +9,39 @@ inspired by http://bl.ocks.org/Sumbera/c6fed35c377a46ff74c3 & need.
8
9
[](#backers)[](#sponsors)
9
10
10
11
## Objective
11
-
* To provide a means of rendering a massive amount of data visually in a way that does not degrade user experience
12
-
* Remaining as simple as possible with current fastest libs
13
-
* Providing the same sort of user experience one would get using standard html and elements
12
+
13
+
- To provide a means of rendering a massive amount of data visually in a way that does not degrade user experience
14
+
- Remaining as simple as possible with current fastest libs
15
+
- Providing the same sort of user experience one would get using standard html and elements
*`vertexShaderSource``{String|Function}` optional glsl vertex shader source, defaults to use `L.glify.shader.vertex`
86
-
*`fragmentShaderSource``{String|Function}` optional glsl fragment shader source, defaults to use `L.glify.shader.fragment.polygon`
87
-
*`click``{Function}` optional event handler for clicking a shape
88
-
*`hover``{Function}` optional event handler for hovering a shape
89
-
*`color``{Function|Object|String}` optional, default is 'random'
90
-
* When `color` is a `Function` its arguments are the `index`:`number` and the `feature`:`object` that is being colored, opacity can optionally be included as `{ a: number }`.
91
-
The result should be of interface `IColor`, example: `{r: number, g: number, b: number, a: number }`.
92
-
*`opacity``{Number}` a value from 0 to 1, default is 0.5. Only used when opacity isn't included on color.
93
-
*`className``{String}` a class name applied to canvas, default is ''
94
-
*`border``{Boolean}` optional, default `false`. When set to `true`, a border with an opacity of `settings.borderOpacity` is displayed.
95
-
*`borderOpacity``{Number}` optional, default `false`. Border opacity for when `settings.boarder` is `true`. Default is 1.
96
-
*`preserveDrawingBuffer``{Boolean}` optional, default `1`, adjusts the border opacity separate from `opacity`.
97
-
* CAUTION: May cause performance issue with large data sets.
98
-
*`pane``{String}` optional, default is `overlayPane`. Can be set to a custom pane.
78
+
### Simple Polygon Usage
79
+
```ts
80
+
L.glify.shapes({
81
+
map,
82
+
data: geoJson,
83
+
click: (e, feature):boolean|void=> {
84
+
// do something when a shape is clicked
85
+
// return false to continue traversing
86
+
},
87
+
hover: (e, feature):boolean|void=> {
88
+
// do something when a shape is hovered
89
+
}
90
+
});
91
+
```
92
+
93
+
## API
94
+
**`L.glify` methods**
95
+
*[`points(options)`](#lglifypointsoptions-object)
96
+
*[`lines(options)`](#lglifylinesoptions-object)
97
+
*[`shapes(options)`](#lglifyshapesoptions-object)
98
+
*[`longitudeFirst()`](#longitudefirst)
99
+
*[`latitudeFirst()`](#latitudefirst)
99
100
100
-
## `L.glify.points` Options
101
+
**`L.glify` properties**
102
+
*[`pointsInstances`](#pointsinstances)
103
+
*[`linesInstances`](#linesinstances)
104
+
*[`shapesInstances`](#shapesinstances)
105
+
106
+
---
107
+
### `L.glify.points(options: object)`
108
+
Adds point data passed in `options.data` to the Leaflet map instance passed in `options.map`.
109
+
#### Returns
110
+
`L.glify.Points` instance
111
+
#### Options
101
112
*`map``{Object}` required leaflet map
102
-
*`data``{Object}` required geojson data
113
+
*`data``{Object}` required geojson `FeatureCollection` object or an array of `[lat: number, lng: number]` arrays
103
114
*`vertexShaderSource``{String|Function}` optional glsl vertex shader source, defaults to use `L.glify.shader.vertex`
104
115
*`fragmentShaderSource``{String|Function}` optional glsl fragment shader source, defaults to use `L.glify.shader.fragment.point`
105
116
*`click``{Function}` optional event handler for clicking a point
@@ -116,10 +127,14 @@ L.glify.lines({
116
127
*`preserveDrawingBuffer``{Boolean}` optional, default `false`, perverse draw buffer on webgl context.
117
128
* CAUTION: May cause performance issue with large data sets.
118
129
*`pane``{String}` optional, default is `overlayPane`. Can be set to a custom pane.
119
-
120
-
## `L.glify.lines` Options
130
+
---
131
+
### `L.glify.lines(options: object)`
132
+
Adds line data passed in `options.data` to the Leaflet map instance passed in `options.map`.
133
+
#### Returns
134
+
`L.glify.Lines` instance
135
+
#### Options
121
136
*`map``{Object}` required leaflet map
122
-
*`data``{Object}` required geojson data
137
+
*`data``{Object}` required geojson `FeatureCollection` object with `geometry.coordinates` arrays being in a `[lat: number, lng: number]` format
123
138
*`vertexShaderSource``{String|Function}` optional glsl vertex shader source, defaults to use `L.glify.shader.vertex`
124
139
*`fragmentShaderSource``{String|Function}` optional glsl fragment shader source, defaults to use `L.glify.shader.fragment.point`
125
140
*`click``{Function}` optional event handler for clicking a line
@@ -138,39 +153,104 @@ L.glify.lines({
138
153
* When `weight` is a `Function` its arguments are gets the `index`:`number`, and the `feature`:`object` that is being drawn
139
154
* CAUTION: Zoom of more than 18 will turn weight internally to 1 to prevent WebGL precision rendering issues.
140
155
*`pane``{String}` optional, default is `overlayPane`. Can be set to a custom pane.
156
+
---
157
+
### `L.glify.shapes(options: object)`
158
+
Adds polygon data passed in `options.data` to the Leaflet map instance passed in `options.map`.
159
+
#### Returns
160
+
`L.glify.Shapes` instance
161
+
#### Options
162
+
*`map``{Object}` required leaflet map
163
+
*`data``{Object}` required geojson `FeatureCollection` object with `geometry.coordinates` arrays being in a `[lng: number, lat: number]` format *Note: `lat` and `lng` are expected in a different order than in `.points()` and `.lines()`*
164
+
*`vertexShaderSource``{String|Function}` optional glsl vertex shader source, defaults to use `L.glify.shader.vertex`
165
+
*`fragmentShaderSource``{String|Function}` optional glsl fragment shader source, defaults to use `L.glify.shader.fragment.polygon`
166
+
*`click``{Function}` optional event handler for clicking a shape
167
+
*`hover``{Function}` optional event handler for hovering a shape
168
+
*`color``{Function|Object|String}` optional, default is 'random'
169
+
* When `color` is a `Function` its arguments are the `index`:`number` and the `feature`:`object` that is being colored, opacity can optionally be included as `{ a: number }`.
170
+
The result should be of interface `IColor`, example: `{r: number, g: number, b: number, a: number }`.
171
+
*`opacity``{Number}` a value from 0 to 1, default is 0.5. Only used when opacity isn't included on color.
172
+
*`className``{String}` a class name applied to canvas, default is ''
173
+
*`border``{Boolean}` optional, default `false`. When set to `true`, a border with an opacity of `settings.borderOpacity` is displayed.
174
+
*`borderOpacity``{Number}` optional, default `false`. Border opacity for when `settings.boarder` is `true`. Default is 1.
175
+
*`preserveDrawingBuffer``{Boolean}` optional, default `1`, adjusts the border opacity separate from `opacity`.
176
+
* CAUTION: May cause performance issue with large data sets.
177
+
*`pane``{String}` optional, default is `overlayPane`. Can be set to a custom pane.
178
+
---
179
+
### `longitudeFirst()`
180
+
Sets the expecetd order of arrays in the `coordinates` array of GeoJSON passed to `options.data` to be `[lng, lat]`
181
+
#### Returns
182
+
The updated `L.glify` instance it was called on
141
183
142
-
## `L.glify` methods/properties
143
-
*`longitudeFirst()`
144
-
*`latitudeFirst()`
145
-
*`pointsInstances`
146
-
*`linesInstances`
147
-
*`shapesInstances`
148
-
*`points(options)`
149
-
*`shapes(options)`
150
-
*`lines(options)`
184
+
---
185
+
### `latitudeFirst()`
186
+
Sets the expecetd order of arrays in the `coordinates` array of GeoJSON passed to `options.data` to be `[lat, lng]`
187
+
#### Returns
188
+
The updated `L.glify` instance it was called on
151
189
190
+
---
191
+
### `pointsInstances`
192
+
All of the `L.glify.Points` instances
193
+
194
+
---
195
+
### `linesInstances`
196
+
All of the `L.glify.Lines` instances
197
+
198
+
---
199
+
### `shapesInstances`
200
+
All of the `L.glify.Shapes` instances
152
201
153
-
## Building
154
202
155
-
There are two ways to package this application: Parcel and WebPack.
203
+
## Building
156
204
157
-
You can build the parcel version by running ``yarn run build-browser``
158
-
You can build the webpack version by running ``yarn run build-browser-webpack``
205
+
You can build the library by running `yarn run build` or `npm run build`
159
206
160
207
## Developing
161
-
Use `yarn serve`
208
+
209
+
Use `yarn serve` or `npm run serve`
162
210
163
211
## Testing
164
-
Use `yarn test`
212
+
213
+
Use `yarn test` or `npm run test`
165
214
166
215
## Update & Remove Data
167
-
L.glify instances can be updated using the `update(data, index)` method.
216
+
`L.glify` instances can be updated using the `update(data, index)` method.
168
217
*`data``{Object}` Lines and Shapes require a single GeoJSON feature. Points require the same data structure as the original object and therefore also accept an array of coordinates.
169
218
*`index``{number}` An integer indicating the index of the element to be updated.
170
219
171
220
An object or some elements of an object are removed using the `remove(index)` method.
172
-
*`index``{number|Array}` optional - An integer or an array of integers specifying the indices of the elements to be removed.
221
+
222
+
-`index``{number|Array}` optional - An integer or an array of integers specifying the indices of the elements to be removed.
223
+
224
+
-`index``{number|Array}` optional - An integer or an array of integers specifying the indices of the elements to be removed.
173
225
If `index` is not defined, the entire object is removed.
0 commit comments