Pages: [1]
  Print  
Author Topic: How to use Google MAP API with flash  (Read 470 times)
Mickey
Gaia Novice
*
Posts: 8


« on: June 29, 2011, 05:00:47 AM »

I am trying to use the Google map API in flash

When i put the code provided by google in my flash folder i am getting an error, call of undefined method Point.

This is the code provided by google

import com.google.maps.LatLng;
import com.google.maps.Map;
import com.google.maps.MapEvent;
import com.google.maps.MapType;

var map:Map = new Map();
map.key = "your_api_key";
map.sensor = "true_or_false";
map.setSize(new Point(stage.stageWidth, stage.stageHeight));
map.addEventListener(MapEvent.MAP_READY, onMapReady);
this.addChild(map);

function onMapReady(event:Event):void {
  map.setCenter(new LatLng(40.736072,-73.992062), 14, MapType.NORMAL_MAP_TYPE);
}

seeing that i am using the gaia framework, i have tried transalating it to this:

package com.mezzo.pages
{
    import com.gaiaframework.templates.AbstractPage;
    import com.gaiaframework.events.*;
    import com.gaiaframework.debug.*;
    import com.gaiaframework.api.*;
    import flash.display.*;
    import flash.events.*;
    import com.greensock.TweenMax;
    import com.google.maps.LatLng;
    import com.google.maps.Map;
    import com.google.maps.MapEvent;
    import com.google.maps.MapType;
   
   
    public class ContactPage extends AbstractPage
    {       
    public var map:Map = new Map();

        public function ContactPage()
        {
            super();
            alpha = 0;
           
        }
        override public function transitionIn():void
        {
            super.transitionIn();
            TweenMax.to(this, 0.3, {alpha:1, onComplete:transitionInComplete});
            map.key = "ABQIAAAA6RfVdhhZiY0vYVJWsVs97BR16Sl5WV4WI7kq5l1CCbZORnxcMhTQz-oQinntj2NJDN5yBIBubPnKjQ";
            map.sensor = "true_or_false";
            map.setSize(new Point(stage.stageWidth, stage.stageHeight));
            map.addEventListener(MapEvent.MAP_READY, onMapReady);
            this.addChild(map);



        }
       
        public function onMapReady(event:Event):void
        {
                  map.setCenter(new LatLng(40.736072,-73.992062), 14, MapType.NORMAL_MAP_TYPE);
        }
        override public function transitionOut():void
        {
            super.transitionOut();
            TweenMax.to(this, 0.3, {alpha:0, onComplete:transitionOutComplete});
        }
    }
}


Could anyone please let me know if they see anything wrong with my code

Thanks
Logged
steven
Gaia Author
Administrator
Gaia Evangelist
*****
Posts: 3871


gaiaframework
WWW
« Reply #1 on: June 29, 2011, 05:40:42 AM »

You have to import the Point class.
Logged

Steven Sacks | Gaia Author
Please support Gaia by donating to the project!  Smiley
Mickey
Gaia Novice
*
Posts: 8


« Reply #2 on: June 29, 2011, 05:55:07 AM »

I added this line"import com.google.maps.Point;" but now i am getting "Definition com.google.maps.Point could not be found".



Logged
steven
Gaia Author
Administrator
Gaia Evangelist
*****
Posts: 3871


gaiaframework
WWW
« Reply #3 on: June 29, 2011, 11:47:02 AM »

http://www.google.com/search?q=Actionscript+3+Point

First result.
Logged

Steven Sacks | Gaia Author
Please support Gaia by donating to the project!  Smiley
cocciu
Gaia Novice
*
Posts: 1


« Reply #4 on: October 14, 2011, 04:44:46 AM »

Thanks, I had the same problem, solved with:

import flash.geom.Point;

... now, I'd like to preload the map with the rest of the page, just to have the map ready when transitionIn starts...

is it possible and how?

thank you, bye

Cocciu
Logged
Pages: [1]
  Print  
 
Jump to:  

TinyPortal v1.0 beta 4 © Bloc