4
0

locationmarker.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. define(["leaflet"], function (L) {
  2. return L.CircleMarker.extend({
  3. outerCircle: {
  4. stroke: false,
  5. color: "#4285F4",
  6. opacity: 1,
  7. fillOpacity: 0.3,
  8. clickable: false,
  9. radius: 16
  10. },
  11. innerCircle: {
  12. stroke: true,
  13. color: "#ffffff",
  14. fillColor: "#4285F4",
  15. weight: 1.5,
  16. clickable: false,
  17. opacity: 1,
  18. fillOpacity: 1,
  19. radius: 7
  20. },
  21. accuracyCircle: {
  22. stroke: true,
  23. color: "#4285F4",
  24. weight: 1,
  25. clickable: false,
  26. opacity: 0.7,
  27. fillOpacity: 0.2
  28. },
  29. initialize: function(latlng) {
  30. this.accuracyCircle = L.circle(latlng, 0, this.accuracyCircle)
  31. this.outerCircle = L.circleMarker(latlng, this.outerCircle)
  32. L.CircleMarker.prototype.initialize.call(this, latlng, this.innerCircle)
  33. this.on("remove", function() {
  34. this._map.removeLayer(this.accuracyCircle)
  35. this._map.removeLayer(this.outerCircle)
  36. })
  37. },
  38. setLatLng: function(latlng) {
  39. this.accuracyCircle.setLatLng(latlng)
  40. this.outerCircle.setLatLng(latlng)
  41. L.CircleMarker.prototype.setLatLng.call(this, latlng)
  42. },
  43. setAccuracy: function(accuracy) {
  44. this.accuracyCircle.setRadius(accuracy)
  45. },
  46. onAdd: function(map) {
  47. this.accuracyCircle.addTo(map).bringToBack()
  48. this.outerCircle.addTo(map)
  49. L.CircleMarker.prototype.onAdd.call(this, map)
  50. }
  51. })
  52. })