Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Maps zoomControl hide and show

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?

like image 923
Stephen Ni Avatar asked Apr 18 '12 07:04

Stephen Ni


1 Answers

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});
    }
like image 127
user10 Avatar answered Sep 28 '22 07:09

user10