/
leaflet.globalwamp.movemarkers.js
52 lines (43 loc) · 1.34 KB
/
leaflet.globalwamp.movemarkers.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
L.Control.ViewCenter = L.Control.extend({
options: {
position: 'topleft',
title: 'move the markers',
forceSeparateButton: false,
vcLatLng: [52.03, 19.27],
vcZoom: 6
},
onAdd: function (map) {
var className = 'leaflet-control-view-center', container;
if(map.zoomControl && !this.options.forceSeparateButton) {
container = map.zoomControl._container;
} else {
container = L.DomUtil.create('div', 'leaflet-bar');
}
this._createButton(this.options, className, container, this.setCenterView, map);
return container;
},
_createButton: function (opts, className, container, fn, context) {
var link = L.DomUtil.create('a', className, container);
link.href = '#';
link.title = opts.title;
var zoom = opts.vcZoom || 6;
L.DomEvent
.addListener(link, 'click', L.DomEvent.stopPropagation)
.addListener(link, 'click', L.DomEvent.preventDefault)
.addListener(link, 'click', function(){
opts.$map.enableMarkerDragging();
}, context);
return link;
}
});
/*
L.Map.addInitHook(function () {
if (this.options.fullscreenControl) {
this.fullscreenControl = L.control.fullscreen(this.options.fullscreenControlOptions);
this.addControl(this.fullscreenControl);
}
});
*/
L.control.viewcenter = function (options) {
return new L.Control.ViewCenter(options);
};