【发布时间】:2010-07-29 06:25:13
【问题描述】:
如何使用 Google Maps API 向我显示没有边栏或搜索栏的全屏地图?我只需要它在移动应用程序中显示特定位置,用户不需要搜索。这可能吗?
另外,如果我提供街道地址,它如何在该位置放置图钉?
【问题讨论】:
标签: javascript html google-maps geocoding
如何使用 Google Maps API 向我显示没有边栏或搜索栏的全屏地图?我只需要它在移动应用程序中显示特定位置,用户不需要搜索。这可能吗?
另外,如果我提供街道地址,它如何在该位置放置图钉?
【问题讨论】:
标签: javascript html google-maps geocoding
假设您计划使用v3 API,您可能需要查看文档的以下部分:
第二个问题可以使用Geocoding。考虑以下简单示例:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<title>Google Maps Geocoding Demo</title>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<script src="http://maps.google.com/maps/api/js?sensor=false"
type="text/javascript"></script>
<style type="text/css">
html { height: 100% }
body { height: 100%; margin: 0px; padding: 0px }
#map { height: 100% }
</style>
</head>
<body>
<div id="map"></div>
<script type="text/javascript">
var address = 'Oxford Street, London, UK';
var map = new google.maps.Map(document.getElementById('map'), {
mapTypeId: google.maps.MapTypeId.TERRAIN,
zoom: 12
});
var geocoder = new google.maps.Geocoder();
geocoder.geocode({
'address': address
},
function(results, status) {
if(status == google.maps.GeocoderStatus.OK) {
new google.maps.Marker({
position: results[0].geometry.location,
map: map
});
map.setCenter(results[0].geometry.location);
}
else {
// Google couldn't geocode this request. Handle appropriately.
}
});
</script>
</body>
</html>
截图:
【讨论】: