1
0

map_marker.js.coffee 1.0 KB

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