Callouts for Non-Features

3617
2
Jump to solution
05-04-2016 02:37 PM
GlennWilson1
New Contributor III


Is it possible to create a callout that shows information for layers in the map.operationalLayers list?

0 Kudos
1 Solution

Accepted Solutions
DiveshGoyal
Esri Regular Contributor

>this returns all of the layers in the mapView.operationalLayers array -- not the layers at the given map-point

Yes, it currently (quartz beta2) returns results for every layer, but we plan to change that to return results for only those layers that have features at that location. For now, you will have to filter out the AGSIdentifyLayerResult that do not have any associated geoElements - that's a sign there were no features for that layer at the location

PS - For quartz beta related questions, please post to forums in the Early Adopter site

https://earlyadopter.esri.com/project/forum/topic.html?cap=59D261350FB84BE48C01CF04BF2A3AA1&forid={F...

View solution in original post

0 Kudos
2 Replies
GlennWilson1
New Contributor III

Well, I feel like I'm the only one developing with the iOS SDK right now -- kinda quiet on the forum.

There's not much in the way of examples utilizing the beta SDK, but after doing a little experimenting, I thought I might have come across a way to do this:

    // respond to touch event

   

    func mapView(mapView: AGSMapView, didLongPressAtPoint screen: CGPoint, mapPoint mappoint: AGSPoint) {

        if self.mapView.callout.hidden {

            let callout = self.mapView.callout

            callout.title = "Location"

            callout.detail = String(format: "x: %.2f, y: %.2f", mappoint.x, mappoint.y)

            callout.accessoryButtonType = UIButtonType.DetailDisclosure

            callout.accessoryButtonHidden = false

           

            let completionBlock: (([AGSIdentifyLayerResult]?, NSError?) -> Void)! = {

                (layers, error) in

                if (error != nil) {

                    callout.detail = "There are no layers where you pressed.  Got error: \(error.debugDescription)\n"

                } else {

                    let details = "There are \(layers?.count) layers where you pressed."

                    print(details)

                   

                    for layer in layers! {

                        print("Layer: \(layer.layerContent.name)=\(layer.layerContent.subLayerContents.count)")

                        print("-->sublayers: \(layer.sublayerResults)")

                    }

                    callout.detail = details

                }

                callout.autoAdjustWidth = true

                callout.showCalloutAt(mappoint, screenOffset: CGPointZero, rotateOffsetWithMap: false, animated: true)

            }

            mapView.identifyLayersAtScreenPoint(screen, tolerance: 5, maximumResultsPerLayer: 2, completion: completionBlock)

        } else {

            self.mapView.callout.dismiss()

        }

    }

   

However, this returns all of the layers in the mapView.operationalLayers array -- not the layers at the given map-point (line 29).  I might be missing something obvious in the logic, but after looking at this for two days, I'm still striking out.  Any ideas/suggestions would be greatly appreciated.

0 Kudos
DiveshGoyal
Esri Regular Contributor

>this returns all of the layers in the mapView.operationalLayers array -- not the layers at the given map-point

Yes, it currently (quartz beta2) returns results for every layer, but we plan to change that to return results for only those layers that have features at that location. For now, you will have to filter out the AGSIdentifyLayerResult that do not have any associated geoElements - that's a sign there were no features for that layer at the location

PS - For quartz beta related questions, please post to forums in the Early Adopter site

https://earlyadopter.esri.com/project/forum/topic.html?cap=59D261350FB84BE48C01CF04BF2A3AA1&forid={F...

View solution in original post

0 Kudos