Current Location Google Maps / jQuery Mobile
Hey, I'm trying to get my current location to register with jquery mobile. However, after many attempts I'm coming up with a blank screen. Can anyone point the direction? (This is the initial events of a rather large project, so baby steps....)
or, my code:
- <!DOCTYPE html>
- z<html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <meta charset="utf-8" />
- <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
- <link rel="stylesheet" href="http://code.jquery.com/mobile/1.0a3/jquery.mobile-1.0a3.min.css" />
-
- <script src="http://code.jquery.com/jquery-1.5.min.js"></script>
- <script src="http://code.jquery.com/mobile/1.0a3/jquery.mobile-1.0a3.min.js"></script>
- <script type="text/javascript" src="scripts/geometa.js"></script>
- <title>Let's Role</title>
- </head>
- <body>
-
- <div id="main" data-role="page" data-theme="a">
- <header data-role="header">
- <h1>Let's Role With That</h1>
- </header>
-
- <div data-role="content">
- <ul id="main-list" data-role="listview">
- <li><a href="#locate">Locate Me</a></li>
- <li><a href="favorites.html">My Favorites</a></li>
- </ul>
- </div>
-
-
- <footer data-role="footer">
-
- <h4>THIS IS THE FOOTER</h4>
- </div>
- </div> <!--/page -->
- <!-- Stage of Second Page -->
- <div data-role="page" id="locate">
-
- <div data-role="header">
- <h1>LOCATE ME</h1>
- </div>
-
- <script type="text/javascript" src="http://www.google.com/jsapi?key=ABQIAAAAlNG2pfxjXcCxkBG2ublnFBQ_HY9EEplWU1n86FkY6-9EgsoTLRSbMiYOA1TNU2HQ-7scaBtUFQfuMg">
- google.load("maps", "2.x");
- google.setOnLoadCallback(function() {
- if (navigator.geolocation) {
- navigator.geolocation.getCurrentPosition(function(position) {
- var location = "";
- if (navigator.geolocation.type == "Gears") {
- if (position.gearsAddress) {
- location = [position.gearsAddress.city, position.gearsAddress.region, position.gearsAddress.country].join(', ');
- } else {
- location = "Zoomed in on: " + position.latitude + ", " + position.longitude;
- }
- } else if (navigator.geolocation.type == "ClientLocation") {
- location = [position.address.city, position.address.region, position.address.country].join(', ');
- } else if (position.coords) {
- position.latitude = position.coords.latitude;
- position.longitude = position.coords.longitude;
- }
- createMap(position.latitude, position.longitude, location);
- }, function() {
- document.getElementById('cantfindyou').innerHTML = "Crap, I don't know. Good hiding!";
- });
- } else {
- document.getElementById('cantfindyou').innerHTML = "Crap, I don't know. Good hiding!";
- }
- });
-
- function createMap(lat, lng, location) {
- var mapElement = document.getElementById("map_canvas");
- mapElement.style.display = 'block';
- var map = new google.maps.Map2(mapElement);
- map.addControl(new GLargeMapControl());
- map.addControl(new GMapTypeControl());
- map.setCenter(new google.maps.LatLng(lat, lng), 13);
- map.openInfoWindow(map.getCenter(), document.createTextNode(location));
- }
- </script>
- <div data-role="content">
- <div id="map_canvas" style="width:300px; height:300px">
- </div><br/>
- <ul data-role="listview" data-inset="true" data-theme="a" data-dividertheme="b">
- <li><a href ="video1.html">Location #1</a></li>
- <li><a href ="video1.html">Location #2</a></li>
- <li><a href ="video1.html">Location #3</a></li>
- <li><a href ="video1.html">Location #4</a></li>
- </ul>
- </div>
-
-
-
- <div data-role="footer">
- <ul data-role="listview" data-inset="true" data-theme="a" data-dividertheme="b">
- <li><a href="#main" data-icon="main">Home</a></li>
- <li><a href="favorites.html" data-icon="vendor">My Favorites</a></li>
- </ul>
-
- </div>
- <div>
- </body>
- </html>