Advanced Flash Components
Search!
Search!
Home >  Forum
  SearchSearch   
Adding UMap Controls......Zoom Control & Position Contro

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.     Forum Index -> UMap ActionScript 3.0
View previous topic :: View next topic  
Author Message
brianmann
AFC Member


Joined: 23 May 2008
Posts: 1

PostPosted: Fri Oct 30, 2009 7:10 pm    Post subject: Adding UMap Controls......Zoom Control & Position Contro Reply with quote

I have been trying to figure out how to add both the Zoom Control and Position Control in Actionscript 3 for the longest time. I am not a coder and wanted to see if anyone can help me out. I took the custom code the AFC provided which does not utilize UMap component, the component is built through the custom code below. Everything runs great, I just cannot get the controls to even show up when I publish it...please take a look at this code and I would really appreciate someone giving me a hand on this!

Code:

import fl.controls.List;
import fl.data.DataProvider;
import com.afcomponents.umap.types.LatLngBounds;

import com.afcomponents.umap.display.routemanager.*;
import com.afcomponents.umap.events.RouteEvent;
import com.afcomponents.umap.core.UMap;
import com.afcomponents.umap.overlays.Polyline;
import com.afcomponents.umap.overlays.RouteLayer;
import com.afcomponents.umap.overlays.Marker;
import com.afcomponents.umap.types.RouteResults;
import com.afcomponents.umap.types.Route;
import com.afcomponents.umap.types.Maneuver;
import com.afcomponents.umap.types.LatLng;
import com.afcomponents.umap.styles.MarkerStyle;
import com.afcomponents.umap.overlays.Marker;
import com.afcomponents.umap.types.LatLng;
import com.afcomponents.umap.types.Align;
import com.afcomponents.umap.styles.DropShadowStyle;
import com.afcomponents.umap.types.Offset;
import com.afcomponents.umap.styles.GeometryStyle;
import com.afcomponents.umap.styles.GradientStyle;
import com.afcomponents.umap.gui.ZoomControl;
//import com.afcomponents.umap.providers.zoomify.ZoomifyProvider;
//import com.afcomponents.umap.display.mapType;
//import com.afcomponents.umap.addControl.mapPosition;
//import com.afcomponents.umap.addControl.mapZoom;

// create UMap instance
var map:UMap = new UMap();
map.setSize(360, 320);
map.x = map.y = 0,0;
addChild(map);

map.setCenter(new LatLng(35, -97.513114), 7);
//map.addControl(new ZoomControl());

// create rotue manager
var rm:RouteManager = new RouteManager(RouteManager.CLOUD_MADE_SERVICE, {apikey:"removed for identity purposes"});
map.addManager(rm);

rm.addEventListener(RouteEvent.READY, rmEvent);
rm.addEventListener(RouteEvent.FAILURE, rmEvent);

function rmEvent(event:RouteEvent):void
{
switch(event.type)
{
case RouteEvent.READY:
var results:RouteResults = event.routeResults;
// show result on the default layer, and get a reference to the created polyline
var poly:Polyline = rm.showResults(results, map.getDefaultLayer());
// set map bounds to the polyline extent
map.setBounds(poly.getBoundsLatLng());

// extract maneuvers
var maneuvers:Array = rm.getAllManeuvers(results);
populateManeuverList(maneuvers);
break;
}
}

zoomControl.visible = true;

// create list
var list:List = new List();
list.setSize(200,400);
list.x = 350;
addChild(list);

list.addItem({label:"please wait..."});
list.enabled = false;

// add listeners to list
list.addEventListener(MouseEvent.CLICK, listClick);

function listClick(event:MouseEvent):void
{
// show the selected maenuver
var m:Maneuver = list.selectedItem.data;

var details:String = "" +
"Distance: " + m.distance + " meters\n" +
"Time: " + m.time + "\n" +
(m.turnType != "" ? "Turn type: " + m.turnType + "\n" : "") +
"Heading: " + m.heading;

map.setBounds(LatLngBounds.fromLatLngArray(m.shape), null, true, 16);
map.openInfoWindow({position:m.shape[0], title:m.narrative, content:details, autoPan:true, offset:new Point(0, 0)});
}

// add maneuvers to the list
function populateManeuverList(maneuvers:Array):void
{
// clear ol items
list.removeAll();
list.enabled = true;
// convert array to DataProvider
list.dataProvider = new DataProvider(maneuvers);
}

// define route options
var options:Object = {};
options.routeType = CloudMadeService.ROUTE_TYPE_FOOT;

// define locations
var locations:Array = [new LatLng(35.51295, -97.51227), new LatLng(35.51353, -97.513114)];

// route!
rm.doRoute(locations, options);

// add start, end marker
map.addOverlay(new Marker({index:"K", position:locations[0], name:"Kimray Sales and Service 4221 N. Santa Fe Oklahoma City, OK"}));
//map.addOverlay(new Marker({index:"B", position:locations[1], name:"Kimray Headquarters 52 NW 42nd Street, Oklahoma City, OK 73118 Phone:405.525.6601"}));
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.     Forum Index -> UMap ActionScript 3.0 All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group