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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
var map;
var ajaxRequest;
var plotlist;
var plotlayers=[];
window.onDomReady = initReady;
window.onDomReady(getLocation);
function initReady(fn) {
if(document.addEventListener) {
document.addEventListener("DOMContentLoaded", fn, false);
}
}
var hfw_lat=51.335,
hfw_lon=12.37,
default_zoom=18;
function getLocation() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(setCoords);
} else {
setCoords({latitude: hfw_lat, longitude: hfw_lon});
}
}
function setCoords(position) {
hfw_lat=position.coords.latitude;
hfw_lon=position.coords.longitude;
initmap();
}
function initmap() {
// set up the map
map = new L.Map('map');
// create the tile layer with correct attribution
//var osmUrl='http://{s}.tile.cloudmade.com/API-key/997/256/{z}/{x}/{y}.png';
var osmUrl='http://otile1.mqcdn.com/tiles/1.0.0/osm/{z}/{x}/{y}.png';
//var osmUrl='http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png';
var osmAttrib='Data, imagery and map information provided by MapQuest, OpenStreetMap <http://www.openstreetmap.org/copyright> and contributors, ODbL <http://wiki.openstreetmap.org/wiki/Legal_FAQ#I_would_like_to_use_OpenStreetMap_maps._How_should_I_credit_you.#> .'
var osm = new L.TileLayer(osmUrl, {minZoom: 12, maxZoom: 18, attribution: osmAttrib});
map.setView(new L.LatLng(hfw_lat, hfw_lon), default_zoom);
map.addLayer(osm);
//L.marker([51.33, 12.35], {icon: hfw1Icon}).addTo(map);
//L.marker([51.37, 12.33], {icon: hfw2Icon}).addTo(map);
//L.marker([51.31, 12.31], {icon: hfw3Icon}).addTo(map);
initForm();
}
function initForm() {
$("#poi_lat").val(hfw_lat);
$("#poi_lon").val(hfw_lon);
}
var hfw1Icon = L.icon({
iconUrl: 'images/new-hfw-marker.png',
shadowUrl: 'images/hfw-marker-shadow.png',
iconSize: [50, 80], // size of the icon
shadowSize: [50, 74], // size of the shadow
iconAnchor: [25, 80], // point of the icon which will correspond to marker's location
shadowAnchor: [25, 60], // the same for the shadow
popupAnchor: [0, 74] // point from which the popup should open relative to the iconAnchor
});
var hfw2Icon = L.icon({
iconUrl: 'images/hfw-puzzle.png',
shadowUrl: 'images/hfw-marker-shadow.png',
iconSize: [50, 80], // size of the icon
shadowSize: [50, 74], // size of the shadow
iconAnchor: [25, 80], // point of the icon which will correspond to marker's location
shadowAnchor: [25, 60], // the same for the shadow
popupAnchor: [0, 74] // point from which the popup should open relative to the iconAnchor
});
var hfw3Icon = L.icon({
iconUrl: 'images/hfw-marker.png',
shadowUrl: 'images/hfw-marker-shadow.png',
iconSize: [50, 74], // size of the icon
shadowSize: [50, 74], // size of the shadow
iconAnchor: [25, 54], // point of the icon which will correspond to marker's location
shadowAnchor: [25, 54], // the same for the shadow
popupAnchor: [0, 74] // point from which the popup should open relative to the iconAnchor
});
|