我的谷歌地图平移缩放控制按钮没有出现

时间:2012-02-13 11:30:30

标签: php google-maps

我在我的项目中实现了谷歌地图。我已经设置了所有必需的东西。我想知道控制图标不像平移,缩放等那样出现。但是我仍然可以通过点击模糊的形状而不是图片按钮进行缩放。有人可以解决这个问题吗?抱怨我的英语不好

<script src="//maps.google.com/maps?file=api&amp;v=2&amp;key=key"
            type="text/javascript"></script>
    <script type="text/javascript">

    function initialize() {
      if (GBrowserIsCompatible()) {
        var map = new GMap2(document.getElementById("map_canvas"));
        var latlng = new GLatLng(<?php echo $lattitude?>, <?php echo $longitude?>);
        map.setCenter(latlng, 13);


        var iconRed = new GIcon(); 
        iconRed.image = 'http://labs.google.com/ridefinder/images/mm_20_red.png';
        iconRed.shadow = 'http://labs.google.com/ridefinder/images/mm_20_shadow.png';
        iconRed.iconSize = new GSize(12, 20);
        iconRed.shadowSize = new GSize(22, 20);
        iconRed.iconAnchor = new GPoint(6, 20);
        iconRed.infoWindowAnchor = new GPoint(5, 1);





          map.addControl(new GSmallMapControl());
          map.addControl(new GMapTypeControl());
          map.addOverlay(new GMarker(latlng));

          var name = "name";
          var address = "address";
          var type = "bar";
          var point = latlng;
          var marker = createMarker(point, name, address, iconRed);
          map.addOverlay(marker);

      }
    }
    function createMarker(point, name, address, iconRed) {
      var marker = new GMarker(point, iconRed);
      var html = "<b>" + name + "</b> <br/>" + address;
      GEvent.addListener(marker, 'click', function() {
        marker.openInfoWindowHtml(html);
      });
      return marker;
    }

1 个答案:

答案 0 :(得分:1)

您不应该将Google Maps API的V2用于您的应用。该版本的API已被弃用。

相反,你应该使用V3:

http://goo.gl/YVKfp