summaryrefslogtreecommitdiff
path: root/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/geolocation.html
blob: 2d41cab3e947acb842aff61e637e1df57f89d1ca (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<head>
<title>Geolocation Permission API Test</title>
<meta content="width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;" name="viewport"/>
<script>
var watchId = 0;

function successHandler(location) {
    var message = document.getElementById("message"), html = [];
    html.push("<img width='256' height='256' src='http://maps.google.com/maps/api/staticmap?center=", location.coords.latitude, ",", location.coords.longitude, "&markers=size:small|color:blue|", location.coords.latitude, ",", location.coords.longitude, "&zoom=14&size=256x256&sensor=false' />");
    html.push("<p>Longitude: ", location.coords.longitude, "</p>");
    html.push("<p>Latitude: ", location.coords.latitude, "</p>");
    html.push("<p>Accuracy: ", location.coords.accuracy, " meters</p>");
    message.innerHTML = html.join("");
}

function errorHandler(error) {
    alert('Attempt to get location failed: ' + error.message);
}

<!-- One shot example -->
navigator.geolocation.getCurrentPosition(successHandler, errorHandler);

</script>
</head>
<body>
<div id="message">Location unknown</div>
</body>
</html>