Advertisement
Guest User

Untitled

a guest
Apr 26th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. // create line feature dependent on time and distance between points
  2. var lineCoords = [],
  3. digitizeLine;
  4.  
  5. ON('click', 'start_digitizing', function(event){
  6. lineCoords = [];
  7. digitizeLine = SETINTERVAL(function() {
  8. if (CURRENTLOCATION()) {
  9. if (lineCoords.length > 0){
  10. var buffer = 0.0003;
  11. var latitude = CURRENTLOCATION().latitude;
  12. var longitude = CURRENTLOCATION().longitude;
  13. var lng = lineCoords[lineCoords.length-1].split(" ")[0];
  14. var lat = lineCoords[lineCoords.length-1].split(" ")[1];
  15. var minLatitude = lat - buffer;
  16. var maxLatitude = lat + buffer;
  17. var minLongitude = lng - buffer;
  18. var maxLongitude = lng + buffer;
  19. if (latitude >= maxLatitude || latitude <= minLatitude || longitude >= maxLongitude || longitude <= minLongitude){
  20. lineCoords.push(CURRENTLOCATION().longitude + ' ' + CURRENTLOCATION().latitude)
  21. }
  22. else
  23. { //do nothing
  24. }
  25. }
  26. else
  27. {
  28. lineCoords.push(CURRENTLOCATION().longitude + ' ' + CURRENTLOCATION().latitude)
  29. }
  30. }
  31. SETVALUE('line', 'LINESTRING (' + lineCoords + ')');
  32. }, 1000);
  33. });
  34.  
  35. ON('click', 'stop_digitizing', function(event) {
  36. CLEARINTERVAL(digitizeLine);
  37. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement