Select to view content in your preferred language

GPS coordinates inputing a graphic?

782
2
Jump to solution
03-11-2014 03:42 PM
HectorChapa
Frequent Contributor
I am try to flash a graphic on the screen based on gps coordinates. This is my code that I have so far. But I dont know how to add a graphic.
How to make that point flash for a while then disappear. But this only adds a graphic for ever never leaves.


mainMap.scale = 3000;        mainMap.centerAt(WebMercatorUtil.geographicToWebMercator(new MapPoint(Number(txtlong.text), Number(txtlat.text))) as MapPoint);        var ptGraphic:Graphic = new Graphic(WebMercatorUtil.geographicToWebMercator(new MapPoint(Number(txtlong.text), Number(txtlat.text))) as MapPoint);        myGraphicsLayer.add(ptGraphic);
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus
Hector,

   Here is a sample:

<?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"                xmlns:esri="http://www.esri.com/2008/ags"                backgroundColor="0xEEEEEE"                pageTitle="locate lat lon then zoom to results">          <s:layout>         <s:VerticalLayout gap="0"/>     </s:layout>          <fx:Script>         <![CDATA[             import com.esri.ags.Graphic;             import com.esri.ags.geometry.WebMercatorMapPoint;                          import spark.filters.GlowFilter;                          private function flashGeo():void             {                 animationFilter.stop();                 var wmp:WebMercatorMapPoint = new WebMercatorMapPoint(Number(txtlong.text), Number(txtlat.text));                 mainMap.centerAt(wmp);                 var ptGraphic:Graphic = new Graphic(wmp);                 myGraphicsLayer.add(ptGraphic);                 animationFilter.targets = [ptGraphic];                 animationFilter.play();             }                          private function removeGra():void             {                 myGraphicsLayer.clear();             }                      ]]>     </fx:Script>          <fx:Declarations>         <!-- Symbol for Query Result as Polygon -->         <esri:SimpleFillSymbol id="sfs" alpha="0.7"/>                  <esri:SimpleMarkerSymbol id="smsFind"                                  alpha="0.9"                                  color="#0000FF"                                  size="11"                                  style="square" />                  <s:AnimateFilter id="animationFilter"                          repeatCount="10"                          duration="500"                          repeatBehavior="reverse"                          effectEnd="removeGra()"                          bitmapFilter="{new spark.filters.GlowFilter(0x0054a6)}">             <s:SimpleMotionPath property="strength"                                  valueFrom="4"                                  valueTo="8"/>             <s:SimpleMotionPath property="blurX"                                  valueFrom="6"                                  valueTo="18"/>             <s:SimpleMotionPath property="blurY"                                  valueFrom="6"                                  valueTo="18"/>         </s:AnimateFilter>     </fx:Declarations>          <s:controlBarLayout>         <s:VerticalLayout gap="10"                           paddingBottom="7"                           paddingLeft="10"                           paddingRight="10"                           paddingTop="7"/>     </s:controlBarLayout>     <s:controlBarContent>         <s:HGroup width="100%" verticalAlign="baseline">             <s:Label text="Enter Lat and Long:"/>             <s:TextInput id="txtlat" text="-3.107"/>             <s:TextInput id="txtlong" text="37.229"/>             <s:Button click="flashGeo()" label="Search"/>         </s:HGroup>     </s:controlBarContent>          <esri:Map  id="mainMap"  x="0" y="10" height="100%" width="100%"  logoVisible="false" >         <esri:extent>             <esri:Extent xmax="-1.08446320657E7" ymax="3100223.793400001"                          xmin="-1.09742216352E7" ymin="3006114.7661000006">                 <esri:SpatialReference wkid="102100" >                 </esri:SpatialReference>             </esri:Extent>         </esri:extent>                  <esri:ArcGISTiledMapServiceLayer url="http://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer" />         <esri:GraphicsLayer id="myGraphicsLayer" />     </esri:Map> </s:Application>

View solution in original post

0 Kudos
2 Replies
RobertScheitlin__GISP
MVP Emeritus
Hector,

   Here is a sample:

<?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"                xmlns:esri="http://www.esri.com/2008/ags"                backgroundColor="0xEEEEEE"                pageTitle="locate lat lon then zoom to results">          <s:layout>         <s:VerticalLayout gap="0"/>     </s:layout>          <fx:Script>         <![CDATA[             import com.esri.ags.Graphic;             import com.esri.ags.geometry.WebMercatorMapPoint;                          import spark.filters.GlowFilter;                          private function flashGeo():void             {                 animationFilter.stop();                 var wmp:WebMercatorMapPoint = new WebMercatorMapPoint(Number(txtlong.text), Number(txtlat.text));                 mainMap.centerAt(wmp);                 var ptGraphic:Graphic = new Graphic(wmp);                 myGraphicsLayer.add(ptGraphic);                 animationFilter.targets = [ptGraphic];                 animationFilter.play();             }                          private function removeGra():void             {                 myGraphicsLayer.clear();             }                      ]]>     </fx:Script>          <fx:Declarations>         <!-- Symbol for Query Result as Polygon -->         <esri:SimpleFillSymbol id="sfs" alpha="0.7"/>                  <esri:SimpleMarkerSymbol id="smsFind"                                  alpha="0.9"                                  color="#0000FF"                                  size="11"                                  style="square" />                  <s:AnimateFilter id="animationFilter"                          repeatCount="10"                          duration="500"                          repeatBehavior="reverse"                          effectEnd="removeGra()"                          bitmapFilter="{new spark.filters.GlowFilter(0x0054a6)}">             <s:SimpleMotionPath property="strength"                                  valueFrom="4"                                  valueTo="8"/>             <s:SimpleMotionPath property="blurX"                                  valueFrom="6"                                  valueTo="18"/>             <s:SimpleMotionPath property="blurY"                                  valueFrom="6"                                  valueTo="18"/>         </s:AnimateFilter>     </fx:Declarations>          <s:controlBarLayout>         <s:VerticalLayout gap="10"                           paddingBottom="7"                           paddingLeft="10"                           paddingRight="10"                           paddingTop="7"/>     </s:controlBarLayout>     <s:controlBarContent>         <s:HGroup width="100%" verticalAlign="baseline">             <s:Label text="Enter Lat and Long:"/>             <s:TextInput id="txtlat" text="-3.107"/>             <s:TextInput id="txtlong" text="37.229"/>             <s:Button click="flashGeo()" label="Search"/>         </s:HGroup>     </s:controlBarContent>          <esri:Map  id="mainMap"  x="0" y="10" height="100%" width="100%"  logoVisible="false" >         <esri:extent>             <esri:Extent xmax="-1.08446320657E7" ymax="3100223.793400001"                          xmin="-1.09742216352E7" ymin="3006114.7661000006">                 <esri:SpatialReference wkid="102100" >                 </esri:SpatialReference>             </esri:Extent>         </esri:extent>                  <esri:ArcGISTiledMapServiceLayer url="http://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer" />         <esri:GraphicsLayer id="myGraphicsLayer" />     </esri:Map> </s:Application>
0 Kudos
HectorChapa
Frequent Contributor
Thank you for your help.
0 Kudos