mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-11-07 23:16:52 +08:00
76 lines
2.5 KiB
HTML
76 lines
2.5 KiB
HTML
<html ng-app="ionic.example">
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<title>Map</title>
|
|
|
|
<!-- Sets initial viewport load and disables zooming -->
|
|
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no">
|
|
<link rel="stylesheet" href="/dist/css/ionic.css">
|
|
<style>
|
|
#map {
|
|
width: 100%;
|
|
height: 100%;
|
|
}
|
|
</style>
|
|
|
|
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.0-rc.3/angular.min.js"></script>
|
|
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.0-rc.3/angular-touch.js"></script>
|
|
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.0-rc.3/angular-animate.js"></script>
|
|
|
|
<script src="/dist/js/ionic.js"></script>
|
|
<script src="/dist/js/ionic-angular.js"></script>
|
|
|
|
<script type="text/javascript"
|
|
src="https://maps.googleapis.com/maps/api/js?key=AIzaSyB16sGmIekuGIvYOfNoW9T44377IU2d2Es&sensor=true"></script>
|
|
|
|
<script type="text/javascript">
|
|
</script>
|
|
</head>
|
|
<body ng-controller="MapCtrl">
|
|
<div class="bar bar-header bar-dark">
|
|
<h1 class="title">Map</h1>
|
|
</div>
|
|
<content has-header="true" has-footer="true">
|
|
<div id="map"></div>
|
|
</content>
|
|
<div class="bar bar-footer bar-dark">
|
|
<button ng-click="centerOnMe()" class="button button-icon"><i class="icon-ios7-navigate"></i></button>
|
|
</div>
|
|
</body>
|
|
|
|
<script>
|
|
angular.module('ionic.example', ['ionic.ui.content', 'ionic.ui.list', 'ionic.service.loading'])
|
|
|
|
.controller('MapCtrl', function($scope, Loading) {
|
|
function initialize() {
|
|
var mapOptions = {
|
|
center: new google.maps.LatLng(43.07493,-89.381388),
|
|
zoom: 16,
|
|
mapTypeId: google.maps.MapTypeId.ROADMAP
|
|
};
|
|
var map = new google.maps.Map(document.getElementById("map"),
|
|
mapOptions);
|
|
$scope.map = map;
|
|
}
|
|
google.maps.event.addDomListener(window, 'load', initialize);
|
|
$scope.centerOnMe = function() {
|
|
if(!$scope.map) {
|
|
return;
|
|
}
|
|
|
|
$scope.loading = Loading.show({
|
|
content: 'Getting current location...',
|
|
showBackdrop: false
|
|
});
|
|
|
|
navigator.geolocation.getCurrentPosition(function(pos) {
|
|
$scope.map.setCenter(new google.maps.LatLng(pos.coords.latitude, pos.coords.longitude));
|
|
$scope.loading.hide();
|
|
}, function(error) {
|
|
alert('Unable to get location: ' + error.message);
|
|
});
|
|
};
|
|
});
|
|
</script>
|
|
</html>
|