繁体   English   中英

带有CSS和图像的Google Map V3缩放按钮

[英]Google Map V3 Zoom Buttons with CSS and Image

如何用自己的图像替换Google Map V3缩放按钮? 我已经尝试了另一篇文章中的以下CSS,但是没有显示出来。 我需要怎么做才能使其显示在地图上? 我也不介意帖子中的第一个解决方案,但我需要将其作为图像并放在地图中而不分开。

#map-container .gm-style > .gmnoprint > .gmnoprint { background: url(/images/map-zoom- controls.png) no-repeat center center !important; width: 42px !important; height: 68px !important; }
#map-container .gm-style > .gmnoprint > .gmnoprint > div > img { display: none !important; }
#map-container .gm-style > .gmnoprint > .gmnoprint div[title="Zoom in"] { top: 2px   !important; left: 2px !important; width: 38px !important; height: 31px !important; }
#map-container .gm-style > .gmnoprint > .gmnoprint div[title="Zoom out"] { top: 35px !important; left: 2px !important; width: 38px !important; height: 30px !important; }

我懂了

<!DOCTYPE html>
<html>
  <head>
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
    <style type="text/css">
      html { height: 100% }
      body { height: 100%; margin: 0; padding: 0 }
      #map-canvas { height: 100% }
#map-canvas .gm-style > .gmnoprint > .gmnoprint { background: url(https://cdn2.iconfinder.com/data/icons/picons-basic-1/57/basic1-171_add_new_plus-128.png) no-repeat center center !important; width: 42px !important; height: 68px !important; }
#map-canvas .gm-style > .gmnoprint > .gmnoprint > div > img { display: none !important; }
#map-canvas .gm-style > .gmnoprint > .gmnoprint div[title="Zoom in"] { top: 2px !important; left: 2px !important; width: 38px !important; height: 31px !important; }
#map-canvas .gm-style > .gmnoprint > .gmnoprint div[title="Zoom out"] { top: 35px !important; left: 2px !important; width: 38px !important; height: 30px !important; }
    </style>
    <script type="text/javascript"
      src="http://maps.google.com/maps/api/js?sensor=false&.js">
    </script>
    <script type="text/javascript">
      function initialize() {
        var mapOptions = {
          center: new google.maps.LatLng(-34.397, 150.644),
          zoom: 8
        };
        var map = new google.maps.Map(document.getElementById("map-canvas"),
            mapOptions);
      }
      google.maps.event.addDomListener(window, 'load', initialize);
    </script>
  </head>
  <body>
    <div id="map-canvas"/>
  </body>
</html>

我添加了大加号按钮来更改缩放

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM