map_marker.js.coffee 941 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. window.map_marker = (map, options = {}) ->
  2. pos = new google.maps.LatLng(options.lat, options.lng)
  3. if options.radius > 0
  4. 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. else
  14. new google.maps.Marker
  15. map: map
  16. position: pos
  17. title: 'Recorded Location'
  18. if options.course
  19. p1 = new LatLon(pos.lat(), pos.lng())
  20. speed = options.speed ? 1
  21. p2 = p1.destinationPoint(options.course, Math.max(0.2, speed) * 0.1)
  22. lineCoordinates = [
  23. pos
  24. new google.maps.LatLng(p2.lat(), p2.lon())
  25. ]
  26. lineSymbol =
  27. path: google.maps.SymbolPath.FORWARD_CLOSED_ARROW
  28. new google.maps.Polyline
  29. map: map
  30. path: lineCoordinates
  31. icons: [
  32. {
  33. icon: lineSymbol
  34. offset: '100%'
  35. }
  36. ]