gtran-kml-data
Convert geojson to kml file and backwards.
This is a fork of gtran-kml.
Installation
npm install gtran-kml-data
Functions
-
setPromiseLib(object)
Specify the promise library. If not, the library will use the native Promise.
-
fromGeoJson(geojson, fileName, options)
Save the geojson into the given file name.
options:
-
name - Specify the feature name using a geojson property. The Default value is 'name'.
-
symbol - Symbol of saved features. Supported styles:
-
Point
-
color - HTML color code or array of RGB values, indicating feature color.
-
alpha - An integer value (0-255), indicating the color opacity
-
scale - Feature size, a float number.
-
icon - Link of feature icons. Some generally used icons can be found here.
-
-
LineString
-
color - HTML color code or array of RGB values, indicating feature color.
-
alpha - An integer value (0-255), indicating the color opacity
-
width - A float value, indicating line width.
-
-
Polygon
-
color - HTML color code or array of RGB values, indicating feature color.
-
alpha - An integer value (0-255), indicating the color opacity
-
fill - A boolean value, indicating whether to fill the polygon.
-
outline - A boolean value, indicating whether to outline the polygon.
-
-
See the detail explaination at KML format reference.
-
-
toGeoJsonData(data)
Read the given data into geojson.
-
toGeoJson(fileName)
Read the given file into geojson.
Use Example
var kml = ;// Specify promise library if necessarykml;// Read KML filekml;var geojson ='type': 'FeatureCollection''features':'type': 'Feature''geometry': "type":"Point""coordinates":-702532459795475436399758607149'properties':'id': 1'Name': 'test';// Define feature symbolvar pointSymbol =color: '#2dcd86'alpha: 255scale: 1icon: 'http://maps.google.com/mapfiles/kml/shapes/square.png';// Save geojson into KML filekml;