Solved

Trouble with Flash and Google Maps

Posted on 2011-09-04
3
576 Views
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:

import com.google.maps.LatLng;
import com.google.maps.Map;
import com.google.maps.MapEvent;
import com.google.maps.MapType;
import com.google.maps.InfoWindowOptions;
import com.google.maps.LatLngBounds;
import com.google.maps.MapMoveEvent;
import com.google.maps.overlays.Marker;
import com.google.maps.overlays.MarkerOptions;
import com.google.maps.interfaces.IPolyline;
import com.google.maps.services.*;

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);
      this.addChild(map);
}
setupMap();

function onMapReady(event:Event):void
{
      dir = new Directions();
      dir.addEventListener(DirectionsEvent.DIRECTIONS_SUCCESS,onDirectionsLoaded);
      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.clearOverlays();
      map.addOverlay(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 com.google.maps.interfaces: IDirections to a possibly unrelated type com.google.maps.services: Directions

Can anyone help me with this issue?

0
Comment
Question by:fool5683
  • 2
3 Comments
 
LVL 29

Expert Comment

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

Accepted Solution

by:
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;

0
 

Author Comment

by:fool5683
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:)
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
This video teaches users how to migrate an existing Wordpress website to a new domain.
The viewer will learn how to dynamically set the form action using jQuery.

708 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now