{"id":16694021,"url":"https://github.com/haoliangyu/gtran-kml","last_synced_at":"2025-04-10T01:33:15.761Z","repository":{"id":2260873,"uuid":"46100799","full_name":"haoliangyu/gtran-kml","owner":"haoliangyu","description":"convert geojson to kml file and backwards","archived":false,"fork":false,"pushed_at":"2022-12-30T17:49:45.000Z","size":390,"stargazers_count":8,"open_issues_count":2,"forks_count":11,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-24T03:11:30.256Z","etag":null,"topics":["conversion","geojson","kml","style","symbol"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/haoliangyu.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-11-13T04:53:49.000Z","updated_at":"2024-10-31T12:38:17.000Z","dependencies_parsed_at":"2023-01-13T11:44:29.884Z","dependency_job_id":null,"html_url":"https://github.com/haoliangyu/gtran-kml","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/haoliangyu%2Fgtran-kml","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/haoliangyu%2Fgtran-kml/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/haoliangyu%2Fgtran-kml/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/haoliangyu%2Fgtran-kml/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/haoliangyu","download_url":"https://codeload.github.com/haoliangyu/gtran-kml/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248140724,"owners_count":21054340,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["conversion","geojson","kml","style","symbol"],"created_at":"2024-10-12T16:43:29.397Z","updated_at":"2025-04-10T01:33:15.742Z","avatar_url":"https://github.com/haoliangyu.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# gtran-kml\n\n[![npm](https://img.shields.io/npm/v/gtran-kml.svg)](https://www.npmjs.com/package/gtran-kml) [![Build Status](https://travis-ci.org/haoliangyu/gtran-kml.svg?branch=master)](https://travis-ci.org/haoliangyu/gtran-kml)\n\nConvert geojson to kml file and backwards.\n\nThis is a sub-project of [gtran](https://github.com/haoliangyu/gtran).\n\n## Installation\n\n```javascript\nnpm install gtran-kml\n```\n\n## Functions\n\n- **fromGeoJson(geojson, fileName, options)**\n\n  Save the geojson into the given file name.\n\n  Since **1.1.11**, it also supports Mapbox's [simplestyle-spec](https://github.com/mapbox/simplestyle-spec).\n\n  options:\n\n  - documentName - Specify the name of the full document. The Default value is **'My KML'**.\n\n  - documentDescription - Specify the description of the full document. The Default value is **'Converted from GeoJson by gtran-kml'**.\n\n  - name - Specify the feature name using a geojson property. The Default value is **'name'**.\n\n  - featureStyleKey - Specify the xml style key in the xml feature properties.\n\n  - symbol - Specify feature Symbol. It accepts an symbol object or a function to return the symbol per feature.\n\n    Supported styles:\n\n    - Point\n\n      - color - HTML color code or array of RGB values, indicating feature color.\n\n      - alpha - An integer value (0-255), indicating the color opacity\n\n      - scale - Feature size, a float number.\n\n      - icon - Link of feature icons. Some generally used icons can be found [here](http://kml4earth.appspot.com/icons.html).\n\n    - LineString\n\n      - color - HTML color code or array of RGB values, indicating feature color.\n\n      - alpha - An integer value (0-255), indicating the color opacity\n\n      - width - A float value, indicating line width.\n\n    - Polygon\n\n      - color - HTML color code or array of RGB values, indicating feature color.\n\n      - alpha - An integer value (0-255), indicating the color opacity\n\n      - fill - A boolean value, indicating whether to fill the polygon.\n\n      - outline - A boolean value, indicating whether to outline the polygon.\n\n  See the detail explaination at [KML format reference](https://developers.google.com/kml/documentation/kmlreference).\n\n  - pretty - Pretty print the output KML. The default value is **false**.\n\n- **toGeoJson(fileName)**\n\n  Read the given file into geojson.\n\n## Use Example\n\n```javascript\nconst kml = require('gtran-kml');\n\n// Specify promise library if necessary\nkml.setPromiseLib(require('bluebird'));\n\n// Read KML file\nkml\n  .toGeoJson('source.kml')\n  .then((object) {\n    const geojson = object;\n  });\n\nconst geojson = {\n  'type': 'FeatureCollection',\n  'features': [{\n    'type': 'Feature',\n    'geometry': {\"type\":\"Point\",\"coordinates\":[-70.2532459795475,43.6399758607149]},\n    'properties': {\n      'id': 1,\n      'Name': 'test'\n    }\n  }]\n};\n\n// Define a symbol for all features in the layer\nconst pointSymbol = {\n  color: '#2dcd86',\n  alpha: 255,\n  scale: 1,\n  icon: 'http://maps.google.com/mapfiles/kml/shapes/square.png'\n};\n\n// Save geojson into KML file\nkml.fromGeoJson(geojson, 'point.kml', {\n  symbol: pointSymbol,\n  name: 'Name'\n})\n\n// Define a symbol for each individual feature\nkml.fromGeoJson(geojson, 'point.kml', {\n  symbol: (feature) =\u003e {\n    return {\n      color: '#2dcd86',\n      alpha: 255 * Math.random(),\n      scale: 1,\n      icon: 'http://maps.google.com/mapfiles/kml/shapes/square.png'\n    }\n  },\n  name: 'Name'\n})\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhaoliangyu%2Fgtran-kml","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhaoliangyu%2Fgtran-kml","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhaoliangyu%2Fgtran-kml/lists"}