1.1.22 • Published 10 years ago

gtran-kml-data v1.1.22

Weekly downloads
4
License
MIT
Repository
github
Last release
10 years ago

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](http://kml4earth.appspot.com/icons.html).
      
      * 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 = require('gtran-kml');

// Specify promise library if necessary
kml.setPromiseLib(require('bluebird'));

// Read KML file
kml.toGeoJson('source.kml')
.then(function(object) {
    var geojson = object;
});

var geojson = {
    'type': 'FeatureCollection',
    'features': [{
        'type': 'Feature',
        'geometry': {"type":"Point","coordinates":[-70.2532459795475,43.6399758607149]},
        'properties': {
          'id': 1,
          'Name': 'test'
        }
    }]
};

// Define feature symbol
var pointSymbol = {
    color: '#2dcd86',
    alpha: 255,
    scale: 1,
    icon: 'http://maps.google.com/mapfiles/kml/shapes/square.png'
};

// Save geojson into KML file
kml.fromGeoJson(geojson, 'point.kml', {
    symbol: pointSymbol,
    name: 'Name'
})
.then(function(fileName) {
    console.log('KML file has been saved at:' + fileName);
});
1.1.22

10 years ago

1.1.21

10 years ago

1.1.20

10 years ago

1.1.19

10 years ago

1.1.18

10 years ago

1.1.17

10 years ago

1.1.16

10 years ago

1.1.15

10 years ago

1.1.14

10 years ago

1.1.13

10 years ago

1.1.12

10 years ago

1.1.11

10 years ago