Select to view content in your preferred language

Attribute Inspector Map Projection error 1009

618
0
01-29-2013 10:04 AM
MikeDahm
Frequent Contributor
I am working with the several of the samples and I keep running into the same error when using the Attribute Inspector with a map that is not in Web Mercator.  I have a map that is in a state plane coordinate system and I have been able to modify the code to work and select in the state plane system.  I am making them for mobile applications.

The error comes in when you select a feature (works fine) and then select an area that has no features. Or select a feature, select ok or close the infowindow and then select an area that has no features.  There are no errors going from one selected features to selecting on another one.  It appears that the problem is when it does not find a feature after it selected a feature it throws an error. 

The samples work as shown so it has to be something with how I modified the projection.

This is the error:

TypeError: Error #1009: Cannot access a property or method of a null object reference.
 at com.esri.ags.layers::FeatureLayer/getEditInfo()
 at com.esri.ags.layers::FeatureLayer/getEditSummary()
 at com.esri.ags.components::AttributeInspector/updateEditSummaryLabel()
 at com.esri.ags.components::AttributeInspector/commitProperties()
 at mx.core::UIComponent/validateProperties()
 at mx.managers::LayoutManager/validateProperties()
 at mx.managers::LayoutManager/doPhasedInstantiation()
 at mx.managers::LayoutManager/doPhasedInstantiationCallback()



This is the extent information in esri:map
<esri:extent>
   <esri:Extent id="initialExtent" 
       xmin="1030071.14636494" ymin="1754363.14766466" xmax="1001254.47674737" ymax="1778602.10963845">
    <esri:SpatialReference wkid="3435"/>
   </esri:Extent>
  </esri:extent>



This is the map_ClickHandler that I modified to work with the state plane projection:
   private function map_mapClickHandler(event:MapMouseEvent):void
   {
    // We create a bounding box around where the user click to intersect the feature's point.
    const point:Point = map.toScreen(map.toMapFromStage(event.stageX, event.stageY));
    var topLeft:MapPoint = map.toMap(new Point(point.x - 10, point.y + 10));
    var bottomRight:MapPoint = map.toMap(new Point(point.x + 10, point.y - 10));
    const spatialReference:SpatialReference = map.spatialReference;
    var selectionExtent:Extent = new Extent(topLeft.x, topLeft.y, bottomRight.x, bottomRight.y, spatialReference) as Extent;
    
    queryMapClick.geometry = selectionExtent;
    myFeatureLayer.selectFeatures(queryMapClick);
    map.infoWindow.hide();
   }

   private function myFeatureLayer_selectionCompleteHandler(event:FeatureLayerEvent):void
   {
    // only show infoWindow if a feature was found
    if (event.featureLayer.numGraphics > 0)
    {
     map.infoWindow.show((queryMapClick.geometry as Extent).center) as MapPoint;
     map.infoWindow.closeButton.addEventListener(MouseEvent.CLICK, infoWindowCloseButtonClickHandler);
    }
    else
    {
     map.infoWindow.hide();     
    }
   }
   



And here is how the code looks from the example:
 private function map_mapClickHandler(event:MapMouseEvent):void
            {
                // We create a bounding box around where the user click to intersect the feature's point.
                const point:Point = map.toScreen(map.toMapFromStage(event.stageX, event.stageY));
                var topLeft:MapPoint = map.toMap(new Point(point.x - 10, point.y + 10));
                var bottomRight:MapPoint = map.toMap(new Point(point.x + 10, point.y - 10));
                const spatialReference:SpatialReference = map.spatialReference;
                var selectionExtent:Extent = WebMercatorUtil.webMercatorToGeographic(new Extent(topLeft.x, topLeft.y, bottomRight.x, bottomRight.y, spatialReference)) as Extent; // create an extent of the clicked point

                queryMapClick.geometry = selectionExtent;
                myFeatureLayer.selectFeatures(queryMapClick);
                map.infoWindow.hide();
            }

            private function myFeatureLayer_selectionCompleteHandler(event:FeatureLayerEvent):void
            {
                // only show infoWindow if a feature was found
                if (event.featureLayer.numGraphics > 0)
                {
                    map.infoWindow.show(WebMercatorUtil.geographicToWebMercator((queryMapClick.geometry as Extent).center) as MapPoint);
                    map.infoWindow.closeButton.addEventListener(MouseEvent.CLICK, infoWindowCloseButtonClickHandler);
                }
            }
Tags (2)
0 Kudos
0 Replies