summaryrefslogtreecommitdiff
path: root/app/assets
diff options
context:
space:
mode:
Diffstat (limited to 'app/assets')
-rw-r--r--app/assets/javascripts/hierfehltwas.js32
-rw-r--r--app/assets/stylesheets/hierfehltwas.css2
2 files changed, 29 insertions, 5 deletions
diff --git a/app/assets/javascripts/hierfehltwas.js b/app/assets/javascripts/hierfehltwas.js
index 96dcfe7..b1a0542 100644
--- a/app/assets/javascripts/hierfehltwas.js
+++ b/app/assets/javascripts/hierfehltwas.js
@@ -5,7 +5,7 @@ var plotlayers=[];
window.onDomReady = initReady;
-window.onDomReady(initmap);
+window.onDomReady(getLocation);
function initReady(fn) {
if(document.addEventListener) {
@@ -13,24 +13,48 @@ function initReady(fn) {
}
}
+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');
+ 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});
+ var osm = new L.TileLayer(osmUrl, {minZoom: 12, maxZoom: 18, attribution: osmAttrib});
- map.setView(new L.LatLng(51.335, 12.37),14);
+ 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({
diff --git a/app/assets/stylesheets/hierfehltwas.css b/app/assets/stylesheets/hierfehltwas.css
index c2042af..aae40b8 100644
--- a/app/assets/stylesheets/hierfehltwas.css
+++ b/app/assets/stylesheets/hierfehltwas.css
@@ -8,6 +8,6 @@ html, body {
}
#map {
- height: 200px;
+ height: 50%;
}