-
Notifications
You must be signed in to change notification settings - Fork 0
/
github.html
62 lines (50 loc) · 1.7 KB
/
github.html
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<!DOCTYPE html>
<html>
<head>
<script src="http://open.mapquestapi.com/sdk/js/v7.0.s/mqa.toolkit.js?key=Fmjtd%7Cluur20uy2g%2C2g%3Do5-9aya1w"></script>
</head>
<body>
<p>Your coordinates:</p>
<p id="demo2"></p>
<script>
getLocation();
var x=document.getElementById("demo2");
function getLocation()
{
if (navigator.geolocation)
{
navigator.geolocation.watchPosition(showPosition);
}
else{x.innerHTML="Geolocation is not supported by this browser.";}
}
function showPosition(position)
{
x.innerHTML="Latitude: " + position.coords.latitude +
"<br>Longitude: " + position.coords.longitude;
lati = position.coords.latitude;
longi = position.coords.longitude;
}
MQA.EventUtil.observe(window, 'load', function() {
/*Create an object for options*/
var options={
elt:document.getElementById('map'), /*ID of element on the page where you want the map added*/
zoom:13, /*initial zoom level of map*/
latLng:{lat:43.0059, lng:12.6000}, /*center of map in latitude/longitude*/
mtype:'osm' /*map type (osm)*/
};
/*Construct an instance of MQA.TileMap with the options object*/
window.map = new MQA.TileMap(options);
MQA.withModule('directions', function() {
map.addRoute([
{latLng: {lat:lati, lng:longi}},
{latLng: {lat:43.0059, lng:12.1000}}],
/*Add options.*/
{ribbonOptions:{draggable:true}}
/*Add the callback function to the route call.*/
);
});
});
</script>
<div id='map' style='width:350px; height:280px;'></div>
</body>
</html>