Added code for leaflet geolocation map
[mediagoblin.git] / mediagoblin / static / js / geolocation-map.js
CommitLineData
836df45d
JW
1$(document).ready(function () {
2 var longitude = Number(
3 $('#tile-map #gps-longitude').val());
4 var latitude = Number(
5 $('#tile-map #gps-latitude').val());
6
7 console.log(longitude, latitude);
8
9 var map = new L.Map('tile-map');
10
11 var mqtileUrl = 'http://otile{s}.mqcdn.com/tiles/1.0.0/osm/{z}/{x}/{y}.jpg';
12 var mqtileAttrib = 'Map data © '
13 + String(new Date().getFullYear())
14 + ' OpenStreetMap contributors, CC-BY-SA.'
15 + ' Imaging © '
16 + String(new Date().getFullYear())
17 + ' <a target="_blank" href="http://mapquest.com">MapQuest</a>.';
18 var mqtile = new L.TileLayer(
19 mqtileUrl,
20 {maxZoom: 18,
21 attribution: mqtileAttrib,
22 subdomains: '1234'});
23
24 var location = new L.LatLng(latitude, longitude); // geographical point (longitude and latitude)
25 map.setView(location, 13).addLayer(mqtile);
26
27 var marker = new L.Marker(location);
28 map.addLayer(marker);
29});