Skip to content

Instantly share code, notes, and snippets.

@kevinhughes27
Last active August 29, 2015 14:25
Show Gist options
  • Save kevinhughes27/b80c387faf6ea38ea144 to your computer and use it in GitHub Desktop.
Save kevinhughes27/b80c387faf6ea38ea144 to your computer and use it in GitHub Desktop.
scrape the actual polygon points from zuluru field drawings
// run by pasting the function into dev console then call it
// can also use something like Custom JavaScript for websites:
// https://chrome.google.com/webstore/detail/custom-javascript-for-web/poakhlngfciodnhlhhgnaaelnpjljija
// name and field are set by Zuluru
function scrape() {
data = ""
fields.forEach(function(field){
// name
data += (name + field.num + " ")
// lat long
data += field.latitude + " " + field.longitude
// poly
vertices = field.field_outline.getPath();
for (var i =0; i < vertices.getLength(); i++) {
var xy = vertices.getAt(i);
data += "p" + i + " (" + xy.lat() + " " + xy.lng() + ') ';
}
data += "\n";
});
console.log(data);
}
// just lat and long
function scrape() {
data = ""
fields.forEach(function(field){
data += (name + field.num + " ")
data += field.latitude + " " + field.longitude
data += "\n";
});
console.log(data);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment