Action
KML Note
Dictate the description for a KML file for import into Google Earth
Steps
-
script
/* Create a KML ready to import to Google Earth. */ /* based on WalkWriter */ // create the draft var d = Draft.create(); d.update(); // create templates const tpl = `<?xml version="1.0" encoding="UTF-8"?> <kml xmlns="http://www.opengis.net/kml/2.2"> <Placemark> <name>[[created|%Y-%m-%d %H:%M:%S]] </name> <description>` const tpl1 =`</description> <Point> <coordinates>[[longitude]], [[latitude]]</coordinates> </Point> </Placemark> </kml>`; // process the templates var x = d.processTemplate(tpl); var y = d.processTemplate(tpl1); // open dictation to insert in current draft var s = editor.dictate(); if (s.length > 0) { d.content = x + s + y; d.addTag("KML"); d.update() } var title = d.processTemplate("[[created|%Y-%m-%d %H-%M-%S]]")+".kml"; var p = Prompt.create(); p.title = "Save as..."; p.addTextField("fileName", "Name", title); p.addButton("Export"); if (p.show()) { var fileName = p.fieldValues["fileName"]; } else { context.cancel(); } // save to the Drafts5 iCloud directory by default var fm = FileManager.create(); var success =fm.write(fileName, d.content); editor.load(d);
Options
-
After Success Nothing Notification Info Log Level Info
Items available in the Drafts Directory are uploaded by community members. Use appropriate caution reviewing downloaded items before use.