Custom controls lost when switching from Streetview to RoadMap view

123 views
Skip to first unread message

Marc

unread,
Dec 20, 2010, 11:09:12 AM12/20/10
to google-map...@googlegroups.com
I have created custom controls on my map using the code:

map.controls[google.maps.ControlPosition.RIGHT_BOTTOM].push(homeControlDiv);

where homeControlDiv is a div that I have created with other controls inside it. The controls are visible when I view the default map in RoadMap mode. When I switch to StreetView and then back to RoadMap view my controls disappear. I think the map object still thinks they are there because if I add the controls again they are added above where they would originally be added.

Anyone got any ideas what is going on and how I can fix this?

Cheers,

Matc

Martin

unread,
Dec 20, 2010, 11:59:22 PM12/20/10
to Google Maps JavaScript API v3
I'd view the map with Firefox and after changing from StreetView back
to RoadMap use Firebug to inspect the map.

Find the custom control div if it's there and look at it's style -
display, visibility and position etc.

Martin.

Marc

unread,
Dec 21, 2010, 6:07:04 AM12/21/10
to Google Maps JavaScript API v3
Hi Martin,

I checked this with firebug and the div that was created is nowhere to
be seen within the firebug source. I have tried a few work arounds but
run into problems with each method.

I have tried the following code to detect when the panorama view is
closed:

google.maps.event.addListener(panorama, 'closeclick', function(){
var toggle = panorama.getVisible();
if(toggle){
newDiv();
}
});

The following function is called to redraw the div on the roadmap. The
HomeControl function contains the code for the innerHTML that I am
creating.

function newDiv(){

// Create the DIV to hold the control and call the HomeControl()
constructor
// passing in this DIV.
var homeControlDiv = document.createElement('DIV');
var homeControl = new HomeControl(homeControlDiv, map);

homeControlDiv.index = 1;

map.controls[google.maps.ControlPosition.RIGHT_BOTTOM].push(homeControlDiv);

}

The wierd thing is that when I call this code the new div is drawn on
the roadmap and I can see the previous div that was created sitting
underneath the default map controls. If I dont call this function the
previous div is not found displayed all.

It would be nice to have the new div I have created overlaying the map
however I reckon I am just going to need to create my div outside the
map area.

Cheers,

Marc
Reply all
Reply to author
Forward
0 new messages