Select to view content in your preferred language

Need Help with reprojection on Geolocation

852
2
08-26-2013 09:32 AM
AronHarris
Emerging Contributor
I am have problems with changing the project of the geoloaction to NAD 1983 California State Plan zone 3 in feet  ???wkid 2227???. What am I missing.

            import flash.sensors.Geolocation;

            private var geo:Geolocation;

            private function myMap_loadHandler(event:MapEvent):void
            {
                if (Geolocation.isSupported)
                {
                    geo = new Geolocation();
                    zoomToCurrentLocationBtn.visible = !geo.muted;
                    geo.addEventListener(StatusEvent.STATUS, geo_statusHandler, false, 0, true);
                }
            }

            private function geo_statusHandler(event:StatusEvent):void
            {
                zoomToCurrentLocationBtn.visible = !geo.muted;
                if (geo.muted)
                {
                    myLocationGraphic.visible = false;
                }
            }

            private function zoomToCurrentLocation_clickHandler(event:MouseEvent):void
            {
                busyIndicator.visible = true;
                zoomToCurrentLocationBtn.enabled = false;
                geo.addEventListener(GeolocationEvent.UPDATE, geo_updateHandler);
            }

            private function geo_updateHandler(event:GeolocationEvent):void
            {
                busyIndicator.visible = false;
                zoomToCurrentLocationBtn.enabled = true;
                geo.removeEventListener(GeolocationEvent.UPDATE, geo_updateHandler);

                if (isNaN(event.longitude) || isNaN(event.longitude))
                {
                    // values are NaN in Airplane mode
                    myLocationGraphic.visible = false;
                }
                else
                {
                    // convert the longitude and latitude values to web mercator as the basemap is in web mercator
                //    var currentLocation:MapPoint = new WebMercatorMapPoint(event.longitude, event.latitude);
    // var outSR2:SpatialReference = new SpatialReference(wkid.selectedItem.data);
    // var currentLocation:MapPoint = new MapPoint(event.longitude, event.latitude, outSR2);
     
     var long:String = event.longitude.toString();
     var lat:String = event.latitude.toString();
     var longnew:Number = Number(long);
     var latnew:Number = Number(lat);
     //var currentLocation:MapPoint = new MapPoint(event.longitude, event.latitude);
     var currentLocation:MapPoint = new MapPoint(longnew,latnew,outSR2);
     //currentLocation.spatialReference = new SpatialReference(4326);
     var outSR2:SpatialReference = new SpatialReference(4326);
     var projParams:ProjectParameters = new ProjectParameters();
     projParams.geometries = [currentLocation];
     outSR2= new SpatialReference(2227);
     projParams.outSpatialReference = outSR2;
     geometryService.project(projParams);
     
    // show.text = longnew.toString();
    // var outSR:SpatialReference = new SpatialReference(2234); 
    // geometryService2.project(event.longitude, event.latitude, outSR); 
    // geometryService2.projectLastResult(currentLocation,outSR); 
     
    // outSR= new SpatialReference(3414);
     
    // geometryService.project(projectParameters);
     
    // currentLocation.spatialReference = new SpatialReference(2227); 
     
                    // show and zoom to current location
                    myLocationGraphic.geometry = currentLocation;
                    myLocationGraphic.visible = true;
                    myMap.centerAt(currentLocation);
                    myMap.level = 8;
                }
            }
 <fx:Declarations>
  <!-- Place non-visual elements (e.g., services, value objects) here -->
  <esri:GeometryService id="geometryService2"
         
         concurrency="last"
         fault="geometryService_faultHandler(event)"
         projectComplete="projectCompleteHandler(event)"
         showBusyCursor="true"
         url="http://stangis/arcgis/rest/services/Utilities/Geometry/GeometryServer"/>
 
 
  <esri:GeometryService id="geometryService"  concurrency="last" fault="geometryService_faultHandler(event)" projectComplete="projectCompleteHandler(event)"  
         url="http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer"/>
 
 
 
 </fx:Declarations>


Thanks
Aron
Public Works/GIS Central
Stanislaus County
Tags (2)
0 Kudos
2 Replies
RobertScheitlin__GISP
MVP Emeritus
Aron,

   Track your code logic line by line and you can see based on all you commenting of lines that you are trying to use outSR2 var before it is declared.
            var long:String = event.longitude.toString();
            var lat:String = event.latitude.toString();
            var longnew:Number = Number(long);
            var latnew:Number = Number(lat);
            var outSR2:SpatialReference = new SpatialReference(4326);
            var currentLocation:MapPoint = new MapPoint(longnew,latnew,outSR2);
            var projParams:ProjectParameters = new ProjectParameters();
            projParams.geometries = [currentLocation];
            projParams.outSpatialReference = new SpatialReference(2227);
            geometryService.project(projParams);
0 Kudos
AronHarris
Emerging Contributor
Thanks..
I was running the debug and  I noticed my wkid  changed  but the X and Y's stayed the same. When I have the gps locate me on the map it move from my California State Plan to  GCS_WGS_1984.What am I missing
0 Kudos