Jump to content
  • 0

Geolocation API


dostel1
 Share

Question

Привет :D .

Помогите разобратся с кодом.

Читал статью

http://www.xiper.net/learn/html/up-and-running/you-are-here/complete-example.html

http://www.xiper.net/learn/html/up-and-running/you-are-here/geo-to-the-rescue.html

Создал пример


<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Dive Into HTML 5</title>
</head>
<body>
<input type="button" onClick="lookup_location()" value="OPA">
<script src="geo.js"></script>
<script src="geo_position_js_simulator.js"></script>
<script>
function lookup_location() {
geo_position_js.getCurrentPosition(show_map, show_map_error);
}
function show_map(loc) {
$("#geo-wrapper").css({'width':'320px','height':'350px'});
var map = new GMap2(document.getElementById("geo-wrapper"));
var center = new GLatLng(loc.coords.latitude, loc.coords.longitude);
map.setCenter(center, 14);
map.addControl(new GSmallMapControl());
map.addControl(new GMapTypeControl());
map.addOverlay(new GMarker(center, {draggable: false, title: "You are here (more or less)"}));
}
function show_map_error() {
$("#live-geolocation").html('Unable to determine your location.');
}

</script>
</body>
</html>

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. See more about our Guidelines and Privacy Policy