Javascript 全屏谷歌地图

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3359937/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-23 04:18:27  来源:igfitidea点击:

Full Screen Google Map

javascripthtmlgoogle-mapsgeocoding

提问by Yazzmi

How can I use Google Maps API to show me a full screen map with no sidebars or search bar? I just need it to show a specific location in a mobile app, users don't need to search. Is this possible?

如何使用 Google Maps API 向我显示没有侧边栏或搜索栏的全屏地图?我只需要它在移动应用程序中显示特定位置,用户不需要搜索。这可能吗?

Also if I provide a street address how can it put a push-pin at the location?

另外,如果我提供街道地址,它如何在该位置放置图钉?

回答by Daniel Vassallo

Assuming you are planning to use the v3 API, you may want to check the following section of the documentation:

假设您计划使用v3 API,您可能需要查看文档的以下部分:

As for your second question, you can use Geocoding. Consider the following simple example:

至于你的第二个问题,你可以使用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>

Screenshot:

截屏:

Full Screen Google Map

全屏谷歌地图