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
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

This article was originally published on Monitis Blog, you can check it here . Today it’s fairly well known that high-performing websites and applications bring in more visitors, higher SEO, and ultimately more sales. By the same token, downtime…
When the s#!t hits the fan, you don’t have time to look up who’s on call, draft emails, call collaborators, or send text messages. An instant chat window is definitely the way to go, especially one like HipChat. HipChat is a true business app. An…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
The goal of the tutorial is to teach the user how to select which audio input to use. Once you have an audio input plugged into the laptop or computer, you will go into the audio input settings and choose which audio input you want to use.

617 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