class RadiusSearchTool

Extends: com.yahoo.maps.tools.PanTool

Class Information

Author
Jess Walls, TopFloor Studio
Version
0.4
Description

Provides a draggable search interface to the Yahoo Maps API

class RadiusSearchTool extends com.yahoo.maps.tools.PanTool

Constructor Summary

RadiusSearchTool() Default Constructor.

Method Summary

initTool() Overrides PanTool definition. Sets up event handlers.
startDragging() Overrides PanTool definition. Captures screen-coordinate information from user mouse drag.
drawSearchBounds() Creates empty movieclip that serves as the container for the circle graphic representing the search area.
drag() Overrides PanTool definition. Initiates drawing routine.
square() Syntactic sugar function.
distanceFromLatLon() Calculate distance (in miles) between two points specified by latitude/longitude with Haversine formula. This code is made available for use by: Chris Veness © 2002-2006
Deg2Rad() Convert degrees to radians.
Rad2Deg() Convert radians to degrees.
removeCircle() Clear the map of the search circle graphic and the mile text.
getSearchBounds() Utility function to calculate corresponding com.yahoo.maps.LatLonRect Object from the specified search radius.
destPointByLatLon() Calculate the Lat/Lon coordinates for a terminal Point given a distance, bearing, and an initial Point.
updateBounds() Zooms map to bounds determined by most recently dragged search radius.
checkZoomLevel() sets private member boolean atStreetLevel depending on the map's zoom level 1 corresponds to street level, 17 is the opposite extreme: the world view.
getSearchCircle() Creates a custom Object containing the lat/lon and radius of the most recent mouse drag representing the search radius.
setSane() Accessor method to set the private sane state variable.
isSane() Accessor method to query the private sane state variable
redrawCircle() Utility method to request the circle graphic be updated.
decode() Debugging method. Converts parameters to Lat/Lon coordinates utilizing Yahoo's undocumented methods: offsetPointToLatLon and localPointToLatLon. Note: The coordinate system of the passed in arguments is user defined.
reCenter() Utility method to recenter the map based on the most recent search radius center.
resetTool() Reinitializes tool to default state.
waitNotify() Overlays "Please Wait" message on map during process of map zoom.
zoomStart() Event handler for tool's associated map zoomStart event. Calls this object's waitNotify method
zoomStop() Event handler removes wait message on map zoomStop event dispatch
panStart() Event handler for this map's panStart event. Updates this tool's sane property.
panStop() Event handler for this map's panStop event. Updates this tool's sane property.
zoom() Event handler for this map's zoom event. Updates this tool's sane property.
registerListeners() Method called on this Ojbect's initTool invocation. Associates this Ojbects event handlers with the associated Yahoo map's events.
unregisterListeners() Removes all currently registered Listeners associated with this Object.
enqueue() Method to manage/track event handler's registered with this Object

Event Summary

onToolMouseDown Overrides PanTool definition. Captures lat/lon information on initial mouseclick and dispatches custom toolClick event
onToolMouseUp Overrides PanTool definition. Dispatches custom drawComplete event.

Constructors

RadiusSearchTool

public function RadiusSearchTool()
Default Constructor.
Parameters:
None

Methods

initTool

public function initTool():Void
Overrides PanTool definition. Sets up event handlers.

startDragging

private function startDragging( event:Object ):Void
Overrides PanTool definition. Captures screen-coordinate information from user mouse drag.

drawSearchBounds

public function drawSearchBounds( centerPoint:mx.graphics.Point, radialPoint:mx.graphics.Point ):Void
Creates empty movieclip that serves as the container for the circle graphic representing the search area.
Parameters:
centerPointThe center Point of the circle representing the search radius.
radialPointA Point on the circumference of the circle representing the search radius.
Returns:
None

drag

private function drag( event:Object ):Void
Overrides PanTool definition. Initiates drawing routine.

square

private function square( n:Number ):Number
Syntactic sugar function.
Parameters:
nA number to be squared.
Returns:
The square of the argument, n

distanceFromLatLon

public function distanceFromLatLon( p1:Object, p2:Object):Number
Calculate distance (in miles) between two points specified by latitude/longitude with Haversine formula. This code is made available for use by: Chris Veness © 2002-2006
Parameters:
p1The initial Point. Note that although parameter type is Object, this method expects an Object of type com.yahoo.maps.LatLon . ( This should be made explicit in the future ).
p2The terminal Point.
Returns:
The distance in miles between the initial Point p1 and the terminal Point p2

Deg2Rad

public function Deg2Rad( deg:Number )
Convert degrees to radians.
Parameters:
degAngle measure in degrees.
Returns:
Corresponing radian measure.

Rad2Deg

public function Rad2Deg( rad:Number )
Convert radians to degrees.
Parameters:
radAngle measure in radians.
Returns:
Corresponding degree measure.

removeCircle

public function removeCircle( ):Void
Clear the map of the search circle graphic and the mile text.
Parameters:
none
Returns:
none

getSearchBounds

private function getSearchBounds( rad:Number, c_latlon:com.yahoo.maps.LatLon ) :com.yahoo.maps.LatLonRect
Utility function to calculate corresponding com.yahoo.maps.LatLonRect Object from the specified search radius.
Parameters:
radRadius in miles
c_latlonCenter of search radius circle as c_latlon:com.yahoo.maps.LatLon
Returns:
com.yahoo.maps.LatLon Object representing the new map bounds. Ideally the circle defined by the given center and radius should be completely inscribed within the determined LatLonRect--need to check that this is indeed the case.

destPointByLatLon

private function destPointByLatLon( distance:Number, bearing:Number, startPoint:Object ):com.yahoo.maps.LatLon
Calculate the Lat/Lon coordinates for a terminal Point given a distance, bearing, and an initial Point.
Parameters:
distancedistance, in miles from intial Point
bearingbearing from initial Point, measured in degrees
Returns:
com.yahoo.maps.LatLon Object representing the terminal Point

updateBounds

public function updateBounds( ):Void
Zooms map to bounds determined by most recently dragged search radius.
Parameters:
None
Returns:
None

checkZoomLevel

private function checkZoomLevel( ):Void
sets private member boolean atStreetLevel depending on the map's zoom level 1 corresponds to street level, 17 is the opposite extreme: the world view.

getSearchCircle

public function getSearchCircle( ):Object
Creates a custom Object containing the lat/lon and radius of the most recent mouse drag representing the search radius.
Parameters:
None
Returns:
circle Object encapsulating the circle's center: circle.center as type com.yahoo.maps.LatLon, and the circle's radius, in miles: circle.radius

setSane

public function setSane( sane:Boolean )
Accessor method to set the private sane state variable.
Parameters:
saneboolean indicating whether the map is in process of a zoom, pan, or other state change that could possibly cause an incoherent result.
Returns:
None

isSane

public function isSane():Boolean
Accessor method to query the private sane state variable
Parameters:
None
Returns:
this RadiusSearchTool's sane state

redrawCircle

public function redrawCircle()
Utility method to request the circle graphic be updated.

decode

public function decode( u0:Number, v0:Number, u1:Number, v1:Number )
Debugging method. Converts parameters to Lat/Lon coordinates utilizing Yahoo's undocumented methods: offsetPointToLatLon and localPointToLatLon. Note: The coordinate system of the passed in arguments is user defined.
Parameters:
u0first coordinate of first Point
v0second coordinate of first Point
u1first coordinate of second Point
v1second coordinate of second Point
Returns:
custom pointWrapper Object containing properties pointWrapper.p1 and pointWrapper.p2 which represent the first and second arguments, respectively, under the tranformation of the Yahoo undocumented methods ( as Lat/Lon Objects ). Subject to change without notice.

reCenter

public function reCenter()
Utility method to recenter the map based on the most recent search radius center.
Parameters:
None
Returns:
None

resetTool

public function resetTool():Void
Reinitializes tool to default state.
Parameters:
None
Returns:
None

waitNotify

private function waitNotify():Void
Overlays "Please Wait" message on map during process of map zoom.
Parameters:
None
Returns:
None

zoomStart

public function zoomStart( event:Object ):Void
Event handler for tool's associated map zoomStart event. Calls this object's waitNotify method

zoomStop

public function zoomStop( event:Object ):Void
Event handler removes wait message on map zoomStop event dispatch

panStart

public function panStart( event:Object ):Void
Event handler for this map's panStart event. Updates this tool's sane property.

panStop

public function panStop( event:Object ):Void
Event handler for this map's panStop event. Updates this tool's sane property.

zoom

public function zoom( event:Object ):Void
Event handler for this map's zoom event. Updates this tool's sane property.

registerListeners

private function registerListeners():Void
Method called on this Ojbect's initTool invocation. Associates this Ojbects event handlers with the associated Yahoo map's events.
Parameters:
None
Returns:
None

unregisterListeners

private function unregisterListeners():Void
Removes all currently registered Listeners associated with this Object.
Parameters:
None
Returns:
None

enqueue

private function enqueue( event_id:String, handler:Object )
Method to manage/track event handler's registered with this Object
Parameters:
None
Returns:
None

Events

onToolMouseDown

public function onToolMouseDown( event:Object ):Void
Overrides PanTool definition. Captures lat/lon information on initial mouseclick and dispatches custom toolClick event

onToolMouseUp

public function onToolMouseUp(event:Object):Void
Overrides PanTool definition. Dispatches custom drawComplete event.

Page generated: 11:47 am on February 27, 2007