hopglass/lib/locationmarker.js

60 lines
1.4 KiB
JavaScript
Raw Normal View History

2015-04-04 19:08:28 +02:00
define(["leaflet"], function (L) {
return L.CircleMarker.extend({
outerCircle: {
stroke: false,
color: "#4285F4",
opacity: 1,
fillOpacity: 0.3,
clickable: false,
radius: 16
},
innerCircle: {
stroke: true,
color: "#ffffff",
fillColor: "#4285F4",
weight: 1.5,
clickable: false,
opacity: 1,
fillOpacity: 1,
radius: 7
},
accuracyCircle: {
stroke: true,
color: "#4285F4",
weight: 1,
clickable: false,
opacity: 0.7,
fillOpacity: 0.2
},
initialize: function (latlng) {
this.accuracyCircle = L.circle(latlng, 0, this.accuracyCircle);
this.outerCircle = L.circleMarker(latlng, this.outerCircle);
L.CircleMarker.prototype.initialize.call(this, latlng, this.innerCircle);
2015-04-04 19:08:28 +02:00
this.on("remove", function () {
this._map.removeLayer(this.accuracyCircle);
this._map.removeLayer(this.outerCircle);
});
2015-04-04 19:08:28 +02:00
},
setLatLng: function (latlng) {
this.accuracyCircle.setLatLng(latlng);
this.outerCircle.setLatLng(latlng);
L.CircleMarker.prototype.setLatLng.call(this, latlng);
2015-04-04 19:08:28 +02:00
},
setAccuracy: function (accuracy) {
this.accuracyCircle.setRadius(accuracy);
2015-04-04 19:08:28 +02:00
},
onAdd: function (map) {
this.accuracyCircle.addTo(map).bringToBack();
this.outerCircle.addTo(map);
L.CircleMarker.prototype.onAdd.call(this, map);
2015-04-04 19:08:28 +02:00
}
});
});