最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Google Maps zoomControl hide and show - Stack Overflow

programmeradmin0浏览0评论

I have encountered a problem when using the custom google maps controls. What I want is to show the zoomControl when switching to the map and hide the zoomControl in other view using map as a static background. My code is like this,

if (isMapView) {
  map.setOptions({
      zoomControl: true,
      zoomControlOptions: {position: google.maps.ControlPosition.RIGHT_TOP}
    });
} else {
  map.setOptions({
      zoomControl: false
    });
}

But this doesnt work, the first switch is fine and latter ones the zoomControl is disappeared. I dont know why. Could anyone give a hand?

I have encountered a problem when using the custom google maps controls. What I want is to show the zoomControl when switching to the map and hide the zoomControl in other view using map as a static background. My code is like this,

if (isMapView) {
  map.setOptions({
      zoomControl: true,
      zoomControlOptions: {position: google.maps.ControlPosition.RIGHT_TOP}
    });
} else {
  map.setOptions({
      zoomControl: false
    });
}

But this doesnt work, the first switch is fine and latter ones the zoomControl is disappeared. I dont know why. Could anyone give a hand?

Share Improve this question edited Apr 18, 2012 at 9:46 Tschareck 4,24912 gold badges49 silver badges79 bronze badges asked Apr 18, 2012 at 7:42 Stephen NiStephen Ni 852 silver badges6 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 8

I am searching for this long time. But your question really helped me. I just did the same thing as you posted. It is working for me.I have added two buttons. On first button click i call DoSomething. on second, DoSomething2. It works fine. Thanks for your post. Look this, if anything helps.

     function DoSomething()
    {
        map.setOptions({zoomControl: true, mapTypeControl: true});
    }

    function DoSomething2()
    {
        map.setOptions({zoomControl: false, mapTypeControl: false});
    }
发布评论

评论列表(0)

  1. 暂无评论