remove custom controls

998 views
Skip to first unread message

Sarath

unread,
Feb 8, 2012, 9:15:46 AM2/8/12
to Google Maps JavaScript API v3
Hi,

I have added a custom control like below:

var searchControlDiv = document.createElement('DIV');
var searchControl = new SearchControl(searchControlDiv, map);

searchControlDiv.index = 1;

map.controls[google.maps.ControlPosition.BOTTOM_CENTER].push(searchControlDiv);

Using the example here: http://code.google.com/apis/maps/documentation/javascript/controls.html#CustomControls
When I try to remove using removeAt, I get error message:

>> Uncaught TypeError: Cannot read property 'parentNode' of undefined

Below is the line of code I am using to remove.

map.controls[google.maps.ControlPosition.BOTTOM_CENTER].removeAt(1);

clear works fine though:
map.controls[google.maps.ControlPosition.BOTTOM_CENTER].clear();

Please advice what am I doing wrong.

Thanks.

Marcelo

unread,
Feb 8, 2012, 11:16:22 AM2/8/12
to Google Maps JavaScript API v3
On Feb 8, 6:15 am, Sarath <msar...@gmail.com> wrote:
> Below is the line of code I am using to remove.
>
> map.controls[google.maps.ControlPosition.BOTTOM_CENTER].removeAt(1);
>

map.controls is an MVCArray and removeAt() is a method of MVCArray, so

map.controls.removeAt(1);

--
Marcelo - http://maps.forum.nu
--
Reply all
Reply to author
Forward
0 new messages