map_marker.js.coffee 1021 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. window.map_marker = (map, options = {}) ->
  2. pos = new google.maps.LatLng(options.lat, options.lng)
  3. if options.radius > 0
  4. marker = new google.maps.Circle
  5. map: map
  6. strokeColor: '#FF0000'
  7. strokeOpacity: 0.8
  8. strokeWeight: 2
  9. fillColor: '#FF0000'
  10. fillOpacity: 0.35
  11. center: pos
  12. radius: options.radius
  13. return marker
  14. else
  15. marker = new google.maps.Marker
  16. map: map
  17. position: pos
  18. title: 'Recorded Location'
  19. return marker
  20. if options.course
  21. p1 = new LatLon(pos.lat(), pos.lng())
  22. speed = options.speed ? 1
  23. p2 = p1.destinationPoint(options.course, Math.max(0.2, speed) * 0.1)
  24. lineCoordinates = [
  25. pos
  26. new google.maps.LatLng(p2.lat(), p2.lon())
  27. ]
  28. lineSymbol =
  29. path: google.maps.SymbolPath.FORWARD_CLOSED_ARROW
  30. arrow = new google.maps.Polyline
  31. map: map
  32. path: lineCoordinates
  33. icons: [
  34. {
  35. icon: lineSymbol
  36. offset: '100%'
  37. }
  38. ]
  39. return arrow