Mouse Click
View live sample | Download as a zip file
Description
Use "pMapBase.addEventListener(MouseEvent.CLICK, vClick)" to add a mouse click event. The code is written in "drawPt.as".
How To Use
1. Download and include "drawPt.as".
2. Copy and modify the codes below.
Code
                                <?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
			   xmlns:s="library://ns.adobe.com/flex/spark"
			   xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600"
			   xmlns:sgw="library://www.supergeotek.com/sgw"
			   
			   initialize="application1_initializeHandler(event)">
	
	<fx:Script>
 
		<![CDATA[
			import Core.ICommand;
			import Core.IDisplayTransformation;
			import Core.ITool;
			import Geometry.Envelope;
			import MapLayer.MapCachedLayer;
			import MapLayer.MapLayer;
			import MapLayer.MapLayerEvents;
			import MapLayer.MapLayerInner;
			import Tool.*;
			import Tool.FullExtentTool;
			import Tool.Identify;
			import Tool.MapZoomStep;
			import Tool.PanTool;
			import Tool.ZoomLastTool;
			import Tool.ZoomTool;
			import mx.events.FlexEvent;
			
			protected function application1_initializeHandler(event:FlexEvent):void 
			{
				var pLyr:MapLayer = new MapLayer();
				pLyr.addEventListener(MapLayerEvents.LOADED, maptilelayer1_LoadedHandler);
				pLyr.Name = "SGW";
				pLyr.Title = "SGW";
				pLyr.ResourcePath="http://sgs.supergeo.com.tw/worldcities/Agent.aspx";
			}
			
			protected function maptilelayer1_LoadedHandler(vEvent:MapLayerEvents):void
			{
				var pStep:MapZoomStep= new MapZoomStep(oMapBase);
				var pLyr:MapLayer = vEvent.currentTarget as MapLayer;
				
				var pExt:Envelope = pLyr.Extent;
				oMapBase.AddLayer(pLyr);
				
				var pTrans:IDisplayTransformation = new LevelTransformation(256 / (pExt.Right - pExt.Left), 0, 15);
				oMapBase.Transformation = pTrans as IDisplayTransformation;
				
				var pExt1:Envelope = new Envelope(-16.998393, 33.774100, 46.929019, -32.278776) as Envelope;
				oMapBase.ZoomMapTo(pExt1);
				
				oMapBase.RefreshMap(true);
				
				//ADD DrawPt which has the mouse click event.
				oMapBase.SelectMapTool(new drawPt(showTip) as ITool);
			}
			
			protected function closeShowTipEvent(event:MouseEvent):void{                
				showTip.visible = false;
			}
		]]>
	</fx:Script>
	<fx:Declarations>
	</fx:Declarations>
	<sgw:MapControl id="oMapBase" width="100%" height="100%">
	</sgw:MapControl>
	<s:BorderContainer id="showTip" visible="false" x="9" y="13" width="176" height="63"   backgroundColor="#FFFFFF" borderWeight="2" cornerRadius="5" alpha="0.85">
		<s:VGroup x="4" y="22" width="142">
		</s:VGroup>           
	</s:BorderContainer>
	<s:Label x="17" y="13" text="SuperGIS Server Flex Website Sample&#xd;--- Click on map to show coordinates" fontWeight="bold" fontSize="30" color="#016B09" backgroundColor="#9ACD32" backgroundAlpha="0.7"/>
</s:Application>