-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmaps.js
58 lines (48 loc) · 2.02 KB
/
maps.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
53
54
55
56
57
58
$(document).ready(function()
{
function add_mapmarker(map, location)
{
var img = new Image();
img.onload = function()
{
var pos = map.locationPoint(location);
var anc = document.createElement('a');
anc.className = 'map-link';
anc.style.width = this.width.toFixed(0) + 'px';
anc.style.height = this.height.toFixed(0) + 'px';
anc.style.left = (pos.x - this.width/2).toFixed(0) + 'px';
anc.style.top = (pos.y - this.height/2).toFixed(0) + 'px';
anc.title = location.name;
anc.href = location.href;
anc.appendChild(img);
map.parent.appendChild(anc);
}
var loc = location.href;
img.src = loc.replace(/\/maps.php(\/.*)?$/, '/images/cross_round_sm.png');
}
function make_map(element, location)
{
var mm = com.modestmaps;
var cm = new mm.StamenProvider('toner-lite');
var dim = {x: $(element).width(), y: $(element).height()};
var map = new mm.Map(element, cm, dim, []);
map.setExtent(location.extent);
add_roundy_corners(map);
add_mapmarker(map, location);
}
$('#maps .map-info').each(function()
{
var lat = parseFloat($(this).find('.geo .latitude').text());
var lon = parseFloat($(this).find('.geo .longitude').text());
var west = parseFloat($(this).find('.geo .bbox-west').text());
var east = parseFloat($(this).find('.geo .bbox-east').text());
var south = parseFloat($(this).find('.geo .bbox-south').text());
var north = parseFloat($(this).find('.geo .bbox-north').text());
var href = $(this).find('a.link').attr('href');
var name = $(this).find('.place-name').text();
var extent = [{lat: north, lon: west}, {lat: south, lon: east}];
var location = {lat: lat, lon: lon, href: href, name: name, extent: extent};
var element = $(this).find('.map-area')[0];
make_map(element, location);
});
});