From bc5af78f470665fc9a7cdbe6a6c1fcdc295c600d Mon Sep 17 00:00:00 2001 From: Lars Henrik Mai Date: Sat, 29 Mar 2014 16:49:54 +0100 Subject: added leaflet js, css and existing code --- app/assets/javascripts/hierfehltwas.js | 67 ++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 app/assets/javascripts/hierfehltwas.js (limited to 'app/assets/javascripts/hierfehltwas.js') diff --git a/app/assets/javascripts/hierfehltwas.js b/app/assets/javascripts/hierfehltwas.js new file mode 100644 index 0000000..96dcfe7 --- /dev/null +++ b/app/assets/javascripts/hierfehltwas.js @@ -0,0 +1,67 @@ +var map; +var ajaxRequest; +var plotlist; +var plotlayers=[]; + + +window.onDomReady = initReady; +window.onDomReady(initmap); + +function initReady(fn) { + if(document.addEventListener) { + document.addEventListener("DOMContentLoaded", fn, false); + } +} + + +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 and contributors, ODbL .' + var osm = new L.TileLayer(osmUrl, {minZoom: 12, maxZoom: 18, attribution: osmAttrib}); + + map.setView(new L.LatLng(51.335, 12.37),14); + 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); + +} + +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 +}); -- cgit v1.2.1