Created
April 10, 2013 18:05
-
-
Save jalalhejazi/5357008 to your computer and use it in GitHub Desktop.
html: Find storkreds i DK
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" /> | |
<meta http-equiv="content-type" content="text/html; charset=UTF-8" /> | |
<title> | |
Find storkreds | |
</title> | |
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.0a1/jquery.mobile-1.0a1.min.css" | |
/> | |
<style type="text/css"> | |
.page-map, .page-map .ui-content, #map-canvas { width: 100%; height: 100%; | |
padding: 0; } .ui-header h1.ui-title {margin-left: 4px; margin-right: 55px} | |
#info {text-align: center} | |
</style> | |
<script src="http://code.jquery.com/jquery-1.4.3.min.js"> | |
</script> | |
<script src="http://code.jquery.com/mobile/1.0a1/jquery.mobile-1.0a1.min.js"> | |
</script> | |
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true"> | |
</script> | |
<script type="text/javascript" src="http://code.google.com/apis/gears/gears_init.js"> | |
</script> | |
<script type="text/javascript"> | |
function detectBrowser() { | |
var useragent = navigator.userAgent; | |
var mapdiv = document.getElementById("map_canvas"); | |
if (useragent.indexOf('iPhone') != -1 || useragent.indexOf('Android') != -1) { | |
mapdiv.style.width = '100%'; | |
mapdiv.style.height = '100%'; | |
} else { | |
mapdiv.style.width = '600px'; | |
mapdiv.style.height = '800px'; | |
} | |
} | |
function initialize() { | |
var DKLatlng = new google.maps.LatLng(56, 10); | |
var browserSupportFlag = new Boolean(); | |
var myOptions = { | |
zoom: 10, | |
// center: DKLatlng, | |
mapTypeId: google.maps.MapTypeId.ROADMAP | |
} | |
var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions); | |
// Try W3C Geolocation (Preferred) | |
if (navigator.geolocation) { | |
browserSupportFlag = true; | |
navigator.geolocation.getCurrentPosition(function(position) { | |
initialLocation = new google.maps.LatLng(position.coords.latitude, position.coords.longitude); | |
map.setCenter(initialLocation); | |
}, function() { | |
handleNoGeolocation(browserSupportFlag); | |
}); | |
// Try Google Gears Geolocation | |
} else if (google.gears) { | |
browserSupportFlag = true; | |
var geo = google.gears.factory.create('beta.geolocation'); | |
geo.getCurrentPosition(function(position) { | |
initialLocation = new google.maps.LatLng(position.latitude, position.longitude); | |
map.setCenter(initialLocation); | |
}, function() { | |
handleNoGeoLocation(browserSupportFlag); | |
}); | |
// Browser doesn't support Geolocation | |
} else { | |
browserSupportFlag = false; | |
handleNoGeolocation(browserSupportFlag); | |
} | |
function handleNoGeolocation(errorFlag) { | |
if (errorFlag == true) { | |
initialLocation = DKLatlng; | |
} else { | |
initialLocation = DKLatlng; | |
} | |
map.setCenter(DKLatlng); | |
} | |
var markersArray = []; | |
google.maps.event.addListener(map, 'click', function(e) { | |
placeMarker(e.latLng); | |
myLatitude = e.latLng.lat(); | |
myLongtitude = e.latLng.lng(); | |
MyCoords = myLatitude + ',' + myLongtitude; | |
$.ajax({ | |
url: "http://geo.oiorest.dk/storkredse/" + MyCoords + ".json?callback=?", | |
dataType: "json", | |
success: visAdresse | |
}) | |
function placeMarker(location) { | |
deleteOverlays(); | |
var marker = new google.maps.Marker({ | |
position: location, | |
map: map | |
}) | |
// infowindow.open(map,marker); | |
markersArray.push(marker); | |
} | |
function deleteOverlays() { | |
if (markersArray) { | |
for (i in markersArray) { | |
markersArray[i].setMap(null); | |
} | |
markersArray.length = 0; | |
} | |
} | |
function visAdresse(adresse) { | |
var tekst = adresse.navn; | |
$(".titel").text(tekst); | |
} | |
}); | |
} | |
</script> | |
</head> | |
<body onload="initialize()"> | |
<div id="frontpage" data-role="page" class="page-map"> | |
<div data-role="header" data-theme="e"> | |
<h1 class="titel"> | |
Find let storkreds | |
</h1> | |
<a href="#about" class="ui-btn-right" data-transition="pop">Om</a> | |
</div> | |
<div data-role="content" id="map_canvas"> | |
</div> | |
</div> | |
<div id="about" data-role="page"> | |
<div data-role="header" data-theme="e"> | |
<h1> | |
Om | |
</h1> | |
<a href="#frontpage" data-rel="back" data-icon="delete" data-iconpos="notext" | |
data-transition="slidedown">Luk</a> | |
</div> | |
<div data-role="content" data-theme="e"> | |
<p> | |
"Find let storkreds" er udviklet af IT- og Telstyrelsen. | |
</p> | |
<p> | |
Data om storkredse stammer fra | |
<a href="http://www.kms.dk/Produktkatalog/DAGI/DAGI-forside.htm" class="ui-link">Danmarks Administrative Geografiske Inddeling (DAGI)</a> | |
, som | |
<a href="http://www.kms.dk" class="ui-link">Kort & Matrikelstyrelsens (KMS)</a> | |
har ophavsretten til. | |
</p> | |
<h2> | |
Licens til koden | |
</h2> | |
<h3> | |
The MIT License | |
</h3> | |
<p> | |
Copyright (c) 2011 Danish National IT and Telecom Agency | |
</p> | |
<p> | |
Permission is hereby granted, free of charge, to any person obtaining | |
a copy of this software and associated documentation files (the "Software"), | |
to deal in the Software without restriction, including without limitation | |
the rights to use, copy, modify, merge, publish, distribute, sublicense, | |
and/or sell copies of the Software, and to permit persons to whom the Software | |
is furnished to do so, subject to the following conditions: | |
</p> | |
<p> | |
The above copyright notice and this permission notice shall be included | |
in all copies or substantial portions of the Software. | |
</p> | |
<p> | |
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS | |
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | |
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | |
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS | |
IN THE SOFTWARE. | |
</p> | |
</div> | |
</div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment