我仍然是HTML5的新手,但我正在尝试使用地理位置添加Google地图以及人们可以找到的几点。当我在提交代码后刷新页面时,它不会出现。有人可以告诉我我哪里出错或更正了代码吗?
网站并不复杂,这是代码:
<!DOCTYPE html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!-->
<html class="no-js">
<!--<![endif]-->
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title></title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="css/bootstrap.min.css">
<style>
body {
padding-top: 50px;
padding-bottom: 20px;
}
</style>
<link rel="stylesheet" href="css/bootstrap-theme.min.css">
<link rel="stylesheet" href="css/main.css">
<script src="js/vendor/modernizr-2.6.2-respond-1.1.0.min.js"></script>
</head>
<body>
<!--[if lt IE 7]>
<p class="browsehappy">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> to improve your experience.</p>
<![endif]-->
<nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand active" href="index.html">Smart Homes<span class="sr-only"></span></a>
</div>
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li class="active"><a href="Testimonial.html">Testimonials<span class="sr-only">(current)</span></a></li>
<li>
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">Thermostat<span class="caret"></span></a>
<ul class="dropdown-menu" role="menu">
<li><a href="MobileThermostat.html">Mobile Thermostat</a></li>
<li><a href="Installation.html">Installation</a></li>
</ul>
</li>
<li>
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">Ordering Info<span class="caret"></span></a>
<ul class="dropdown-menu" role="menu">
<li><a href="#">How To Order/Cost</a></li>
<li><a href="#">New Letter Registration</a></li>
</ul>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">Energy Saving <span class="caret"></span></a>
<ul class="dropdown-menu" role="menu">
<li><a href="Tips.html">Energy Tips</a></li>
<li><a href="Tutorial.html">Take A Tour</a></li>
<li class="divider"></li>
<li><a href="#">FAQ</a></li>
</ul>
</li>
<li><a href="#">Contact Us<span class="sr-only"></span></a></li>
</ul>
</div>
<div id="navbar" class="navbar-collapse collapse">
<form class="navbar-form navbar-right" role="form">
<div class="form-group">
<input type="text" placeholder="Email" class="form-control">
</div>
<div class="form-group">
<input type="password" placeholder="Password" class="form-control">
</div>
<button type="submit" class="btn btn-success">Sign in</button>
</form>
<div>
<a href="RegisterWithSmartHomes.html">Create An Account</a>
</div>
</div><!--/.navbar-collapse -->
</div>
</nav>
<!-- Main jumbotron for a primary marketing message or call to action -->
<div class="jumbotron">
<div class="container">
<h1>Find Our Products Nearby </h1>
<h2>Use Our Map</h2>
<p>
Use our map below to find a location near you.
</p>
</div>
<div>
<script>
function initMap() {
var map = new google.maps.Map(document.getElementById('map'), {
center: {lat: -34.397, lng: 150.644},
zoom: 13
});
var infoWindow = new google.maps.InfoWindow({map: map});
// Try HTML5 geolocation.
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function(position) {
var pos = {
lat: position.coords.latitude,
lng: position.coords.longitude
};
infoWindow.setPosition(pos);
infoWindow.setContent('Location found.');
map.setCenter(pos);
}, function() {
handleLocationError(true, infoWindow, map.getCenter());
});
} else {
// Browser doesn't support Geolocation
handleLocationError(false, infoWindow, map.getCenter());
}
}
function handleLocationError(browserHasGeolocation, infoWindow, pos) {
infoWindow.setPosition(pos);
infoWindow.setContent(browserHasGeolocation ?
'Error: The Geolocation service failed.' :
'Error: Your browser doesn\'t support geolocation.');
}
</script>
</div>
<div class="container">
<!-- Example row of columns -->
<div class="row">
<div class="col-md-4">
<h2>Mobile Thermostat</h2>
<p>Learn more about the mobile thermostat by following this link. </p>
<p><a class="btn btn-default" href="MobileThermostat.html" role="button">View details »</a></p>
</div>
<div class="col-md-4">
<h2>Ordering and Cost</h2>
<p>Get cost and ordering information here. You'll be surprised and how economical the Smart Homes Mobile Thermostat system is, and how much it will save you over time. </p>
<p><a class="btn btn-default" href="#" role="button">View details »</a></p>
</div>
<div class="col-md-4">
<h2>Customer Testimonials</h2>
<p>Find out how our customers feel about their decision to buy our system, and how it has improved their lives, reduced costs, providing comfort and convenience.</p>
<p><a class="btn btn-default" href="Testimonial.html" role="button">View details »</a></p>
</div>
</div>
<hr>
<footer>
<p>© Smart Homes Inc. 2015</p>
</footer>
</div> <!-- /container -->
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script>window.jQuery || document.write('<script src="js/vendor/jquery-1.11.1.min.js"><\/script>')</script>
<script src="js/vendor/bootstrap.min.js"></script>
<script src="js/main.js"></script>
<script src="js/playVidoeChosen.js"></script>
<!-- Google Analytics: change UA-XXXXX-X to be your site's ID. -->
<script>
(function (b, o, i, l, e, r) {
b.GoogleAnalyticsObject = l; b[l] || (b[l] =
function () { (b[l].q = b[l].q || []).push(arguments) }); b[l].l = +new Date;
e = o.createElement(i); r = o.getElementsByTagName(i)[0];
e.src = '//www.google-analytics.com/analytics.js';
r.parentNode.insertBefore(e, r)
}(window, document, 'script', 'ga'));
ga('create', 'UA-XXXXX-X'); ga('send', 'pageview');
</script>
</body>
</html>
答案 0 :(得分:0)
你添加了一个带有id&#39; map&#39;的div你的HTML代码?因为我没有找到带有id的地图&#39; map&#39;在你的代码中。也许您需要添加以下代码。
self.pushBehavior.active = YES;