Trouble with Flash and Google Maps

Posted on 2011-09-04
Last Modified: 2013-12-25
Can someone please help me. I am in the process of building a Flash application the utilizes the Google Map APi. I have downloaded the following code:


var dir:Directions;
var polyline:IPolyline;
var map:Map;
function setupMap()
      map = new Map();
      map.key ="ABQIAAAAjf2cvxDuc5J1E9CrJXmy9RQrAB2acdB4QgEQtVMeGDLCPkNwtRR8XAwx0MS9MI4RYmgwJ-jCIN9QaQ";
      map.setSize(new Point(400,400));
      map.x = 0;
      map.y = 0;
      map.addEventListener(MapEvent.MAP_READY, onMapReady);

function onMapReady(event:Event):void
      dir = new Directions();
      dir.load("645 Carlton Road, Markham, ON to Fawnbrook Circle, Markham, ON");
function onDirectionsLoaded(event:DirectionsEvent):void
      var returnedDirection:Directions = event.directions;

      var startLatLng:LatLng = returnedDirection.getRoute(0).getStep(0).latLng;
      var endLatLng:LatLng = returnedDirection.getRoute(returnedDirection.numRoutes - 1).endLatLng;

      polyline = returnedDirection.createPolyline();

      // Remove everything from map and add back the markers and polyline
      map.addOverlay(new Marker(startLatLng));
      map.addOverlay(new Marker(endLatLng));
      map.setCenter(returnedDirection.bounds.getCenter(), map.getBoundsZoomLevel(returnedDirection.bounds));

I am unable to generate a map but Iam getting the following error:

Line 36 1118: Implicit coercion of a value with static type IDirections to a possibly unrelated type Directions

Can anyone help me with this issue?

Question by:fool5683
  • 2
LVL 29

Expert Comment

ID: 36480990
where is in your sample line 36?
LVL 29

Accepted Solution

dgofman earned 500 total points
ID: 36481009
To fix your problem it's simple you need just cast to Direction

function onDirectionsLoaded(event:DirectionsEvent):void
            var returnedDirection:Directions = event.directions as Directions;


Author Comment

ID: 36481276
dgofman you are the man! I am attempting to develop a Flash application that will allow me to utilize the google map api to plot routes and distances. Your solution was awesome! I am going to start asking more questions to get this done as soon as possible! So stay tuned ...O Wise One:)

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Edit a page at 8 72
tag title an image 13 34
paypal ipn url 5 81
ajaxSubmit is giving me an error 1 47
I've been asked to discuss some of the UX activities that I'm using with my team. Here I will share some details about how we approach UX projects.
Because your company can’t afford for you to make SEO mistakes, you’ll want to ensure you’re taking the right steps each and every time you post a new piece of content. This list of optimization do’s and don’ts can help you become an SEO wizard.
The goal of the tutorial is to teach the user how to live broadcast using Flash Media Live Encoder and connecting it to YouTube to broadcast. Log into your Youtube account, choose live stream settings, start live stream from Flash Media Live Enc…
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question