13
如何使用Google Maps API向我顯示沒有側邊欄或搜索欄的全屏地圖?我只需要它在移動應用中顯示特定位置,用戶就不需要搜索。這可能嗎?全屏Google地圖
另外,如果我提供一個街道地址,它怎麼能把一個推針在該位置?
如何使用Google Maps API向我顯示沒有側邊欄或搜索欄的全屏地圖?我只需要它在移動應用中顯示特定位置,用戶就不需要搜索。這可能嗎?全屏Google地圖
另外,如果我提供一個街道地址,它怎麼能把一個推針在該位置?
假設你計劃使用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>
截圖: