Yahoo got fantastic web service components to use at free of cost. One of them which caught my attention to use for jewelinfo4u.com was yahoo map web services components. They have Adobe flex version yahoo map component, which gives flexibility to build custom map applications.
I used yahoo flex map component to build gemstone mines map application using adobe flex builder 2. Beauty of this application is the mines location is dynamic, in the sense the mines geometric locations (Lat, long) stored in a database and an xml web service is used to get the location information. The flex map component is used to display the maps in any format chosen by the user (satellite, hybrid, Map). The mine locations are denoted using markers by calling the xml web service. Check the following pages for the action in live.
http://www.jewelinfo4u.com/Amber_Mines.aspx
http://www.jewelinfo4u.com/Amazonite_Mines.aspx
http://www.jewelinfo4u.com/Turquoise_Mines_Map.aspx
http://www.jewelinfo4u.com/Onyx_Mines.aspx
http://www.jewelinfo4u.com/Aquamarine_Mines.aspx
http://www.jewelinfo4u.com/Ruby_Mines_Map.aspx
http://www.jewelinfo4u.com/Emerald_Mines.aspx
http://www.jewelinfo4u.com/Sapphire_Mines.aspx
http://www.jewelinfo4u.com/Interactive_Amethyst_Mines_Map.aspx
http://www.jewelinfo4u.com/Alexandrite_Mines.aspx
http://www.jewelinfo4u.com/Agate_Mines.aspx
For more information on getting started guide for Yahoo flex map component:
http://developer.yahoo.com/maps/flash/flexGettingStarted.html
Sample code I used here:
import flash.utils.getTimer;
import mx.controls.Alert;
import com.yahoo.webapis.maps.methodgroups.*;
import mx.rpc.events.ResultEvent;
import mx.rpc.http.HTTPService;
import flash.events.*;
import mx.collections.ArrayCollection;
private const SWFDOMID:String = "Amber_Mines";
private const UNIQUEID:int = getTimer();
private const YAHOOAPIKEY:String = "Yahoo app key";
private const MAPSWF:String = "as2map.swf";
private var latLonController:LatLonController;
private var mapController:MapController;
private var service:HTTPService;
public function GetMines(url:String):void
{
service = new HTTPService();
service.url = url;
service.addEventListener(ResultEvent.RESULT, resultHandler);
service.send();
}
private function resultHandler(event:ResultEvent):void
{
var result:ArrayCollection = event.result.Mines.Mine as ArrayCollection;
var i:int;
for(i = 0; i < result.length; i++)
{
fillLatLong(result.getItemAt(i));
}
}
private function fillLatLong(test:Object):void
{
var sName:String;
var sPlace:String;
var sState:String;
var sCountry:String;
sName = test.Name;
sState = test.State;
sCountry = test.Country;
sState = sState+ ", " + sCountry;
var markerArgs:Object = {index:'A!', title:sName,description:sState, markerColor:0xff0000, strokeColor:0xDFDFDF};
latLonController.addMarkerByLatLon("CustomPOIMarker",Number(test.Lat), Number(test.Long),markerArgs);
}
private function init():void {
myAS2Map.addEventListener('onMapLoad', onMapLoaded);
myAS2Map.addEventListener('onMapError', onMapError);
}
private function onMapLoaded(ev:Object):void {
var panTools:PanTool = new PanTool(myAS2Map);
panTools.setPanTool(true);
mapController = new MapController(myAS2Map);
var widgets:Widgets = new Widgets(myAS2Map);
widgets.showNavigatorWidget();
widgets.showSatelliteControlWidget();
latLonController = new LatLonController(myAS2Map);
GetMines("http://www.jewelinfo4u.com/utils/GetMines.aspx ");
}
private function onMapError(errorCode:String, httpStatus:String):void {
Alert.show(errorCode + '\n' + httpStatus, 'Load Error');
}
]]>