Select to view content in your preferred language

Move Point Feature to Current GPS Location

2205
2
Jump to solution
04-01-2013 07:30 AM
MattSheehan
Deactivated User
On a mobile I have a feature layer and am trying to move a point feature to my current GPS location. The following is a code snippet. I'm finding the only way I can get the point to reposition is if I refresh() the featurelayer. Is there any way to avoid needing to do this?
   
        
    if(FlexGlobals.topLevelApplication.geoLong != null && FlexGlobals.topLevelApplication.geoLat != null)     {                                                 //Remove the glow                         ModelEdit.instance.editor.attributeInspector.activeFeature.filters = [];                         //Remove attribute inspector                         okButton.dispatchEvent(new MouseEvent(MouseEvent.CLICK, true, false));                                                   var geoLocateIt:MapPoint = new MapPoint(FlexGlobals.topLevelApplication.geoLong, FlexGlobals.topLevelApplication.geoLat, Model.instance.map.spatialReference);                         var geoLocateWebMerc:* = WebMercatorUtil.geographicToWebMercator(geoLocateIt);                                                 (ModelEdit.instance.editor.attributeInspector.activeFeature.geometry as MapPoint).update(geoLocateWebMerc.x, geoLocateWebMerc.y, Model.instance.map.spatialReference);                                                                         //HOW DO I AVOID REFRESHING THE FEATURELAYER                         (ModelEdit.instance.editor.attributeInspector.activeFeature.graphicsLayer as FeatureLayer).refresh();                                                 (ModelEdit.instance.editor.attributeInspector.activeFeature.graphicsLayer as FeatureLayer).applyEdits(null, [ModelEdit.instance.editor.attributeInspector.activeFeature], null);                         (ModelEdit.instance.editor.attributeInspector.activeFeature.graphicsLayer as FeatureLayer).addEventListener(FeatureLayerEvent.EDITS_COMPLETE, editCompleteHdlr)                           }


Thanks

--Rory
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
YannCabon
Esri Contributor
Hi,

Instead of updating the mapPoint, set it to the feature:
var geom:MapPoint = ModelEdit.instance.editor.attributeInspector.activeFeature.geometry as MapPoint; geom.update(geoLocateWebMerc.x, geoLocateWebMerc.y, Model.instance.map.spatialReference); ModelEdit.instance.editor.attributeInspector.activeFeature.geometry = geom;


This should redraw only that feature.


On a mobile I have a feature layer and am trying to move a point feature to my current GPS location. The following is a code snippet. I'm finding the only way I can get the point to reposition is if I refresh() the featurelayer. Is there any way to avoid needing to do this?
   
        
    if(FlexGlobals.topLevelApplication.geoLong != null && FlexGlobals.topLevelApplication.geoLat != null)     {                                                 //Remove the glow                         ModelEdit.instance.editor.attributeInspector.activeFeature.filters = [];                         //Remove attribute inspector                         okButton.dispatchEvent(new MouseEvent(MouseEvent.CLICK, true, false));                                                   var geoLocateIt:MapPoint = new MapPoint(FlexGlobals.topLevelApplication.geoLong, FlexGlobals.topLevelApplication.geoLat, Model.instance.map.spatialReference);                         var geoLocateWebMerc:* = WebMercatorUtil.geographicToWebMercator(geoLocateIt);                                                 (ModelEdit.instance.editor.attributeInspector.activeFeature.geometry as MapPoint).update(geoLocateWebMerc.x, geoLocateWebMerc.y, Model.instance.map.spatialReference);                                                                         //HOW DO I AVOID REFRESHING THE FEATURELAYER                         (ModelEdit.instance.editor.attributeInspector.activeFeature.graphicsLayer as FeatureLayer).refresh();                                                 (ModelEdit.instance.editor.attributeInspector.activeFeature.graphicsLayer as FeatureLayer).applyEdits(null, [ModelEdit.instance.editor.attributeInspector.activeFeature], null);                         (ModelEdit.instance.editor.attributeInspector.activeFeature.graphicsLayer as FeatureLayer).addEventListener(FeatureLayerEvent.EDITS_COMPLETE, editCompleteHdlr)                           }


Thanks

--Rory

View solution in original post

0 Kudos
2 Replies
YannCabon
Esri Contributor
Hi,

Instead of updating the mapPoint, set it to the feature:
var geom:MapPoint = ModelEdit.instance.editor.attributeInspector.activeFeature.geometry as MapPoint; geom.update(geoLocateWebMerc.x, geoLocateWebMerc.y, Model.instance.map.spatialReference); ModelEdit.instance.editor.attributeInspector.activeFeature.geometry = geom;


This should redraw only that feature.


On a mobile I have a feature layer and am trying to move a point feature to my current GPS location. The following is a code snippet. I'm finding the only way I can get the point to reposition is if I refresh() the featurelayer. Is there any way to avoid needing to do this?
   
        
    if(FlexGlobals.topLevelApplication.geoLong != null && FlexGlobals.topLevelApplication.geoLat != null)     {                                                 //Remove the glow                         ModelEdit.instance.editor.attributeInspector.activeFeature.filters = [];                         //Remove attribute inspector                         okButton.dispatchEvent(new MouseEvent(MouseEvent.CLICK, true, false));                                                   var geoLocateIt:MapPoint = new MapPoint(FlexGlobals.topLevelApplication.geoLong, FlexGlobals.topLevelApplication.geoLat, Model.instance.map.spatialReference);                         var geoLocateWebMerc:* = WebMercatorUtil.geographicToWebMercator(geoLocateIt);                                                 (ModelEdit.instance.editor.attributeInspector.activeFeature.geometry as MapPoint).update(geoLocateWebMerc.x, geoLocateWebMerc.y, Model.instance.map.spatialReference);                                                                         //HOW DO I AVOID REFRESHING THE FEATURELAYER                         (ModelEdit.instance.editor.attributeInspector.activeFeature.graphicsLayer as FeatureLayer).refresh();                                                 (ModelEdit.instance.editor.attributeInspector.activeFeature.graphicsLayer as FeatureLayer).applyEdits(null, [ModelEdit.instance.editor.attributeInspector.activeFeature], null);                         (ModelEdit.instance.editor.attributeInspector.activeFeature.graphicsLayer as FeatureLayer).addEventListener(FeatureLayerEvent.EDITS_COMPLETE, editCompleteHdlr)                           }


Thanks

--Rory
0 Kudos
MattSheehan
Deactivated User
Thanks Yann. That works nicely.
0 Kudos