-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathgeojson.js
More file actions
32 lines (30 loc) · 1.21 KB
/
geojson.js
File metadata and controls
32 lines (30 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
var extend = require('xtend')
var createMap = require('./utils/map')
var createClassName = require('./utils/classname')
var defaultProps = {
tagName: 'div',
editable: true,
size: 'normal',
attributes: {}
}
/**
Create a virtual-dom geojson data-field for use with [data-ui](https://github.com/editdata/data-ui).
* @name createGeoJSONField
* @param {Object} options an options object, including any properties you can pass to leaflet & virtual-dom/h
* @param {String} options.accessToken mapbox access token for using their API
* @param {Object} options.tileLayer Leaflet tilelayer, default is osm tiles
* @param {String} options.imagePath path to leaflet images
* @param {Boolean} options.editable false for static mode, default is true for editable mode
* @returns field
* @example
* var createGeoJSONField = require('data-field-geojson')
* var field = createGeoJSONField(h, options, geojsonObject)
*/
module.exports = function createGeoJSONField (h, options, geojsonObject) {
options = extend(defaultProps, options)
options.dataType = 'geojson'
var value = geojsonObject || options.value
var map = createMap(value, options)
options.className = createClassName(options)
return h(options.tagName, options, map)
}