1 | function sleep(ms) { |
via https://stackoverflow.com/questions/951021/what-is-the-javascript-version-of-sleep
layer chnage source
其实是重建
1 | function setLayerSource (layerId, source, sourceLayer) { |
1 | function sleep(ms) { |
via https://stackoverflow.com/questions/951021/what-is-the-javascript-version-of-sleep
其实是重建
1 | function setLayerSource (layerId, source, sourceLayer) { |
1 | const DEFAULTS = { |
直接字面量创建
1 | var objA = {}; |
new关键字创建
1 | var objB = new Object(); |
Object.create 创建
一个完整的版本
1 | import StarRating from 'vue-star-rating' |
1 | import InfoWindowContent from '../InfoWindowContent.vue' |
1 | // 添加Popup对象 |
options.preserveDrawingBuffer
If true , the map’s canvas can be exported to a PNG using map.getCanvas().toDataURL() . This is false by default as a performance optimization.
1 | map.getCanvas().toDataURL() |
Returns an array of GeoJSON Feature objects representing visible features that satisfy the query parameters.
https://docs.mapbox.com/mapbox-gl-js/api/map/#map#queryrenderedfeatures
1 | // Find all features within a static bounding box |
1 | // Find all features within a bounding box around a point |
1 | // Query all rendered features from a single layer |
Returns an array of GeoJSON Feature objects representing features within the specified vector tile or GeoJSON source that satisfy the query parameters.
https://docs.mapbox.com/mapbox-gl-js/api/map/#map#querysourcefeatures
1 | // Find all features in one source layer in a vector source |
1 | // If an image with the ID 'cat' already exists in the style's sprite, |
1 | "icon-color": [ |
https://stackoverflow.com/questions/17964757/how-to-prune-delete-nodes-in-nested-tree-like-json
1 | var a = [ |
简单说,就是允许碰撞
1 | "icon-ignore-placement": true, // 不管下面 |
1 | var aa = { "type": "Polygon", |
最外面多一层
1 | var aa = { "type": "MultiPolygon", |
test.map.getSource(‘temp_polygon’).setData(aa)
1 | var aa = { |
1 | var aa = { |
1 | var clone = Object.assign({}, {a: 1, b: 2, c: 3}); |
这个不完美
1 | var clone2 = Object.assign({}, {a: 1, b: 2, c: 3}, {b: undefined}); |
1 | const x = {a: 1, b: 2, c: 3, z:26}; |
1 | const obj = { a: 1, b: 2, c: 3, d: 4 } |
lodash
1 | _.omit(x, 'b') |
package.json 的 eslintConfig(如果已经有 eslintrc.js )
1 | "rules": { |
1 | let a = {a:1,b:{c:{d:2}}} |
via https://www.samanthaming.com/tidbits/70-3-ways-to-clone-objects/
1 | const purchase = [ |
两头对齐
1 | Masks 9.99 |
1 | const bankNumber = '2222 2222 2222 2222'; |
类似滴:
deep copy (or deep clone): lodash _.cloneDeep, Ramda, a custom function, JSON.parse() / JSON.stringify(), and rfdc
For the best performance, the library rfdc (Really Fast Deep Clone) will deep copy about 400% faster than lodash’s _.cloneDeep