Link to home
Start Free TrialLog in
Avatar of Dreadart
Dreadart

asked on

API google map all over my pages

Hi,
I am a AS3 and Flash CS4 newb user. I created a simple website which's structure I explain below:
the website has 4 main layers:
1- Houses my script
2- Houses my menu which has movieclips as bottons
3- Houses the content of the pages (1 movie clip with 7 frames for different  content)
4- Houses my background design
On the movieclip of fram 3 I inserted 2 layers:
1- Houses my AS3
2- Houses the different frames of the movie with different content)
The problem is that I inserted my script on frame 5 of the AS3 layer for it to display a couple of google maps on the content layer of the movie clip. When I test the website and navigate to the frame 5 where the maps are being displayed, everything displayed ok BUT when I navigate away from that frame the google maps do not go away. They simply go on top of the content of the rest my my movieclip frames overriding whatever content I have.
Here is the code that I used for to insert the google maps. Any help please?
----
import com.google.maps.*;
import com.google.maps.overlays.*;
import com.google.maps.controls.*;

var gomap:Map = new Map()
gomap.key = "API key";

gomap.setSize(new Point(220,250))

gomap.x = -260
gomap.y = 155

gomap.addEventListener(MapEvent.MAP_READY, onMapReady);

this.addChild(gomap);

function onMapReady(e:Event):void
   {

      gomap.enableScrollWheelZoom();
      
      var nav_position:ControlPosition = new ControlPosition(ControlPosition.ANCHOR_TOP_LEFT, -65,0);
      var myNavPos:NavigationControl = new NavigationControl();
    myNavPos.setControlPosition(nav_position);      
      gomap.addControl(myNavPos);
      
      var view_position:ControlPosition = new ControlPosition(ControlPosition.ANCHOR_TOP_LEFT, 10,260);
      var myViewPos:MapTypeControl = new MapTypeControl();
    myViewPos.setControlPosition(view_position);      
      gomap.addControl(myViewPos);
   
      gomap.setCenter(new LatLng(33.789817, -118.185720),14,MapType.NORMAL_MAP_TYPE);
            
      gomap.removeMapType(MapType.PHYSICAL_MAP_TYPE);
            
      var myMarker :Marker = new Marker(new LatLng(33.789817, -118.185720),

      
      new MarkerOptions({icon:new marker1(),                   
                                                             hasShadow: false}));
      gomap.addOverlay(myMarker);
      }
      
      
      var gomap2:Map = new Map()
gomap2.key = "API key";

gomap2.setSize(new Point(220,250))

gomap2.x = 80
gomap2.y = 155

gomap2.addEventListener(MapEvent.MAP_READY, onMapReady2);

this.addChild(gomap2);

function onMapReady2(e:Event):void
   {

      gomap2.enableScrollWheelZoom();
      
      var nav_position:ControlPosition = new ControlPosition(ControlPosition.ANCHOR_TOP_LEFT, -65,0);
      var myNavPos:NavigationControl = new NavigationControl();
    myNavPos.setControlPosition(nav_position);      
      gomap2.addControl(myNavPos);
      
      var view_position:ControlPosition = new ControlPosition(ControlPosition.ANCHOR_TOP_LEFT, 10,260);
      var myViewPos:MapTypeControl = new MapTypeControl();
    myViewPos.setControlPosition(view_position);      
      gomap2.addControl(myViewPos);
   
      gomap2.setCenter(new LatLng(33.790291,-118.167781),14,MapType.NORMAL_MAP_TYPE);
            
      gomap2.removeMapType(MapType.PHYSICAL_MAP_TYPE);
            
      var myMarker :Marker = new Marker(new LatLng(33.790291,-118.167781),

      
      new MarkerOptions({icon:new marker2(),                   
                                                             hasShadow: false}));
      gomap2.addOverlay(myMarker);
      }
Avatar of AreDubya
AreDubya
Flag of United States of America image

Dreadart,

When you navigate away from the map page, you need to have:

this.removeChild(gomap);

if that doesn't work, try it without the "this".

AreDubya
ASKER CERTIFIED SOLUTION
Avatar of AreDubya
AreDubya
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Dreadart
Dreadart

ASKER

Thank you! You are a wizard!