-
Notifications
You must be signed in to change notification settings - Fork 0
/
twitter_geo.js
executable file
·44 lines (38 loc) · 1.35 KB
/
twitter_geo.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
(function ($) {
Drupal.behaviors.twitter_geo = {
attach: function(context, settings) {
var map = L.map('twitter_geo_map', {
//center: [51.505, -0.09],
minZoom: 1,
});
map.setView([$('input[name="lat"]').val(), $('input[name="lon"]').val()], $('input[name="zoom"]').val());
L.tileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
maxZoom: 18
}).addTo(map);
var marker = L.marker(map.getCenter()).addTo(map);
var circle = L.circle(map.getCenter(), $('select[name="distance"]').val() * 1609.34, {
color: 'red',
fillColor: '#f03',
fillOpacity: 0.5
}).addTo(map);
var OSMGeocoder = new L.Control.OSMGeocoder({collapsed: false});
map.addControl(OSMGeocoder);
refresh();
//map.on('drag', drag);
map.on('move', refresh);
map.on('moveend', refresh);
//map.on('zoomend', refresh);
$('select[name="distance"]').change(function() {
refresh();
});
function refresh() {
center = map.getCenter();
$('input[name="lat"]').val(center.lat);
$('input[name="lon"]').val(center.lng);
$('input[name="zoom"]').val(map.getZoom());
circle.setLatLng(map.getCenter());
circle.setRadius($('select[name="distance"]').val() * 1609.34);
}
}
}
})(jQuery);