+ Reply to Thread
Results 1 to 13 of 13

Thread: Adding graphics to AGSWebMap

  1. #1
    c.f. ong
    Join Date
    Feb 2012
    Posts
    43
    Points
    0
    Answers Provided
    2


    0

    Default Adding graphics to AGSWebMap

    Hello

    I've created an AGSWebMap and displayed it in an AGSMapView. However, I've problems now to add AGSGrpahic objects to the map view. No problem if I were to use AGSTiledMapServiceLayer instead of AGSWebMap. Is this the expected behaviour with using AGSWebMap ?

    Thanks.

    Rgds
    Ong CF

  2. #2
    Nimesh Jarecha

    Join Date
    Oct 2009
    Posts
    883
    Points
    493
    Answers Provided
    106


    0

    Default Re: Adding graphics to AGSWebMap

    What all layers are available in the AGSWebMap?

    Regards,
    Nimesh

  3. #3
    c.f. ong
    Join Date
    Feb 2012
    Posts
    43
    Points
    0
    Answers Provided
    2


    0

    Default Re: Adding graphics to AGSWebMap

    Hello

    Got it now. Need to set up (i.e. add AGSGraphicsLayer and other stuff) in didOpenWebMap as follows:

    - (void)didOpenWebMapAGSWebMap *)webMap intoMapViewAGSMapView *)mapView
    {
    // Once all the layers in web map are loaded
    // Add AGSGraphicslayer on top
    NSLog(@"didOpenWebMap");

    [self setUpAfterOpenWebMap];
    }

    - (void)webMapDidLoadAGSWebMap *)webMap
    {
    NSLog(@"webMapDidLoad");

    for (AGSWebMapLayerInfo *li in webMap.operationalLayers)
    {
    NSLog(@"title %@; layerId %@; layerType %@; mode %d; layers count %d", li.title, li.layerId, li.layerType, li.mode, [li.layers count]);
    AGSPopupInfo *pi = li.popupInfo;
    NSLog(@"title %@; description %@; allowEdit %@", pi.title, pi.description, pi.allowEdit);
    for (AGSPopupFieldInfo *fi in pi.fieldInfos)
    {
    NSLog(@"fieldName %@", fi.fieldName);
    }
    }
    }

    Also, I've tried the following:

    1. Set up web map with id = c14cef13d247471da5c0262db843c09e (my own web map)
    Added a shapefile (SP_BDY_polyline) and configured pop-up
    However, webMapDidLoad does not show AGSPopupInfo and AGSPopupFieldInfo as configured

    2. For web map with id = b31153c71c6c429a8b24c1751a50d3ad (from Feature Editing sample)
    webMapDidLoad shows AGSPopupInfo and AGSPopupFieldInfo as configured

    Questions:

    1. Any way for web map to treat my shapefile as a Feature Layer?

    2. Is it necessary for web map to be based on a Feature Layer from a Feature Server for AGSPopupInfo and AGSPopupFieldInfo to be configured properly?

    Thanks.

    Rgds
    Ong CF

  4. #4
    Nimesh Jarecha

    Join Date
    Oct 2009
    Posts
    883
    Points
    493
    Answers Provided
    106


    1

    Default Re: Adding graphics to AGSWebMap

    1. Any way for web map to treat my shapefile as a Feature Layer?
    The shape file added to the web map is being treated as feature collection (ultimately, it is a feature layer but in this case all features resided in the web map and not in the server like a feature layer from a feature server).

    2. Is it necessary for web map to be based on a Feature Layer from a Feature Server for AGSPopupInfo and AGSPopupFieldInfo to be configured properly?
    No, you can configure popupInfo for the layer based on a shape file (feature collection). You are not able to find the popup info because you are looking at a wrong place. Just change your code like below and you'll see what you want to

    Code:
       for (AGSWebMapLayerInfo *li in webMap.operationalLayers)
        {
            NSLog(@"title %@; layerId %@; layerType %@; mode %d; layers count %d", li.title, li.layerId, li.layerType, li.mode, [li.layers count]);
            
            if(li.featureCollection) {
               
                AGSWebMapFeatureCollection *wmfc = li.featureCollection;
                for (AGSWebMapLayerInfo *fcli in wmfc.layers)
                {
                    AGSPopupInfo *pi = fcli.popupInfo;
                    NSLog(@"title %@; description %@; allowEdit %@", pi.title, pi.description, pi.allowEdit);
                    for (AGSPopupFieldInfo *fi in pi.fieldInfos)
                    {
                        NSLog(@"fieldName %@", fi.fieldName); 
                    }
                }
            }
        }
    Regards,
    Nimesh

  5. #5
    c.f. ong
    Join Date
    Feb 2012
    Posts
    43
    Points
    0
    Answers Provided
    2


    0

    Default Re: Adding graphics to AGSWebMap

    Hi Nimesh

    Thanks for your reply. Yes, now I can see the AGSPopupInfo and AGSPopupFieldInfo details for the shapefile's featureCollection.

    Next, I set up the delegate method below so that when I click on the accessory button for the graphic, I can see the fieldNames and their values in the popupVC.

    - (void)mapViewAGSMapView *)mapView didClickCalloutAccessoryButtonForGraphicAGSGraphic *)graphic
    {
    NSLog(@"didClickCalloutAccessoryButtonForGraphic");

    AGSPopupInfo *info = [AGSPopupInfo popupInfoForGraphic:graphic];
    for (AGSPopupFieldInfo *fieldInfo in info.fieldInfos)
    {
    NSLog(@"fieldName = %@; label = %@", fieldInfo.fieldName, fieldInfo.label);
    }

    self.popupVC = [[AGSPopupsContainerViewController alloc] initWithWebMap:self.webmap forFeature:graphic usingNavigationControllerStack:NO];
    self.popupVC.delegate = self;
    }

    However, I don't see the AGSPopupInfo stuff based on the graphic selected using NSLog. In that case, how do I then set the AGSPopupInfo's properties to allow editing and so on?

    Thanks.

    Rgds
    Ong CF

  6. #6
    Nimesh Jarecha

    Join Date
    Oct 2009
    Posts
    883
    Points
    493
    Answers Provided
    106


    1

    Default Re: Adding graphics to AGSWebMap

    You should find the popupInfo like this,

    Code:
    AGSPopupInfo *popupInfo = [self.webMap popupInfoForFeatureLayer:(AGSFeatureLayer *)graphic.layer];
    You can edit feature collections only on arcgis.com not on any mobile clients like iOS, android etc. Hence, editing will be FALSE by default. If you want to you can set 'popupInfo.allowEdit = TRUE;' explicitly after creating a popupInfo but you won't be able to save the edits.

    Regards,
    Nimesh

  7. #7
    c.f. ong
    Join Date
    Feb 2012
    Posts
    43
    Points
    0
    Answers Provided
    2


    0
    This post is marked as the answer

    Default Re: Adding graphics to AGSWebMap

    Hi Nimesh

    Thanks for your reply. I'm now able to edit the feature attribute values on the client side. You're right that the edits remain locally and are not updated to the web map hosted on ArcGIS.com. Is there a way to overcome this? Such as to save the web map from the client side after updating like what's done at ArcGIS.com. I've created the web map based on credentials as those to sign-in to ArcGIS.com.

    Does it mean that edits can only be updated for features hosted on a Feature Server?

    Thanks.

    Rgds
    Ong CF

  8. #8
    Nimesh Jarecha

    Join Date
    Oct 2009
    Posts
    883
    Points
    493
    Answers Provided
    106


    1

    Default Re: Adding graphics to AGSWebMap

    Thanks for your reply. I'm now able to edit the feature attribute values on the client side. You're right that the edits remain locally and are not updated to the web map hosted on ArcGIS.com. Is there a way to overcome this? Such as to save the web map from the client side after updating like what's done at ArcGIS.com. I've created the web map based on credentials as those to sign-in to ArcGIS.com.
    Unfortunately, there is not way to over come this. The feature collections can be edited only on arcgis.com.

    Does it mean that edits can only be updated for features hosted on a Feature Server?
    Yes!

    Regards,
    Nimesh

  9. #9
    c.f. ong
    Join Date
    Feb 2012
    Posts
    43
    Points
    0
    Answers Provided
    2


    0

    Default Re: Adding graphics to AGSWebMap

    Hi Nimesh

    Thanks so much for all your replies that have given me a better understanding of the underlying concepts!

    Rgds
    Ong CF

  10. #10
    Nimesh Jarecha

    Join Date
    Oct 2009
    Posts
    883
    Points
    493
    Answers Provided
    106


    0

    Default Re: Adding graphics to AGSWebMap

    You're welcome!

    Regards,
    Nimesh

  11. #11
    c.f. ong
    Join Date
    Feb 2012
    Posts
    43
    Points
    0
    Answers Provided
    2


    0

    Default Re: Adding graphics to AGSWebMap

    Quote Originally Posted by nrjarecha View Post
    Unfortunately, there is not way to over come this. The feature collections can be edited only on arcgis.com.



    Yes!

    Regards,
    Nimesh
    Hi Nimesh

    I'm coming back to this thread with the release of Version 2.3. That is, can the limitation as discussed above be overcome with Version 2.3? Would it work if the webmap is hosted via ArcGIS on-line subscription?

    Thanks.

    Rgds
    Ong CF

  12. #12
    Nimesh Jarecha

    Join Date
    Oct 2009
    Posts
    883
    Points
    493
    Answers Provided
    106


    0

    Default Re: Adding graphics to AGSWebMap

    Unfortunately, No, there is no way to overcome that limitation, not with v2.3 or ArcGIS Online subscription.

    Regards,
    Nimesh

  13. #13
    c.f. ong
    Join Date
    Feb 2012
    Posts
    43
    Points
    0
    Answers Provided
    2


    0

    Default Re: Adding graphics to AGSWebMap

    Hi Nimesh

    Thanks for your reply.

    Rgds
    Ong CF

+ Reply to Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts