It's 2012 all up in here
[mediagoblin.git] / mediagoblin / static / js / geolocation-map.js
CommitLineData
9542a2ba
JW
1/**
2 * GNU MediaGoblin -- federated, autonomous media hosting
cf29e8a8 3 * Copyright (C) 2011, 2012 MediaGoblin contributors. See AUTHORS.
9542a2ba
JW
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU Affero General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU Affero General Public License for more details.
14 *
15 * You should have received a copy of the GNU Affero General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
836df45d
JW
19$(document).ready(function () {
20 var longitude = Number(
21 $('#tile-map #gps-longitude').val());
22 var latitude = Number(
23 $('#tile-map #gps-latitude').val());
24
9542a2ba 25 // Get a new map instance attached and element with id="tile-map"
836df45d
JW
26 var map = new L.Map('tile-map');
27
28 var mqtileUrl = 'http://otile{s}.mqcdn.com/tiles/1.0.0/osm/{z}/{x}/{y}.jpg';
29 var mqtileAttrib = 'Map data &copy; '
30 + String(new Date().getFullYear())
31 + ' OpenStreetMap contributors, CC-BY-SA.'
32 + ' Imaging &copy; '
33 + String(new Date().getFullYear())
34 + ' <a target="_blank" href="http://mapquest.com">MapQuest</a>.';
35 var mqtile = new L.TileLayer(
36 mqtileUrl,
37 {maxZoom: 18,
38 attribution: mqtileAttrib,
39 subdomains: '1234'});
40
9542a2ba 41 var location = new L.LatLng(latitude, longitude);
836df45d
JW
42 map.setView(location, 13).addLayer(mqtile);
43
44 var marker = new L.Marker(location);
45 map.addLayer(marker);
46});