戻る

ソース

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0">
<title></title>
<script src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
<script src="http://code.jquery.com/mobile/1.1.0/jquery.mobile-1.1.0.min.js"></script>
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.1.0/jquery.mobile-1.1.0.min.css">
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true"></script>
<script type="text/javascript">
$("#index").live("pageshow",function(){
	
	$("#btn").live("tap",function(){
		var address = $("#address").val();
		var geocoder = new google.maps.Geocoder();
		geocoder.geocode({
			'address':address
		},
		function(results, status){
			var options = {
				zoom:18,
				mapTypeId: google.maps.MapTypeId.ROADMAP
			}
			if(status == google.maps.GeocoderStatus.OK) {
				var map = new google.maps.Map(document.getElementById("gmap"), options);
				map.setCenter(results[0].geometry.location);
				var marker = new google.maps.Marker({
					map: map, 
					position: results[0].geometry.location
				});
			}
			else {
				console.log("ステータス:" + status);
			}
		});
	});
	
});
</script>
<style>
#gmap{
	height: 500px;
	background: #eee;
	border: 1px solid #e1deda;
}
</style>
</head>
<body>
<div data-role="page" id="index">
	<div data-role="header">
		<h1>住所から地図を取得する</h1>
	</div>
	<div data-role="content">
		<div data-role="fieldcontain">
			<label for="lat">住所:</label>
			<input type="text" id="address" value="大阪府大阪市中央区大手前1丁目6−8">
		</div>
		<div data-role="fieldcontain">
			<input type="button" id="btn" value="地図">
		</div>
		<div id="gmap"></div>
	</div>
	<div data-role="footer" data-position="fixed">
		<h4>Yohsuke Nakano</h4>
	</div>
</div>
</body>
</html>

inserted by FC2 system