Select to view content in your preferred language

How to Buddy Up AGO Tiled Service with AGO Feature Service?

752
1
06-10-2014 07:21 AM
deleted-user-Jie3eyjOl9XM
Deactivated User
I've got a map, and I've added a hosted tile service. I did NOT create the map from a webmap like this:
arcgisUtils.createMap(webmap,"map")

Rather, I just added the layer using the AGO endpoint for the tiled layer, like this:
map.addLayer(
   new ArcGISTiledMapServiceLayer("http://tiles.arcgis.com/tiles/...", {})
);


I realize that I can't identify on a hosted tile service. But, upon map click, I'd like to access the underlying feature data. I don't want to display the popup, because I need to do more than that.

I certainly don't want to add the Feature Service to my map, because I don't want to render all of those vectors, and I need to use the cached service for display.

I've read about how you can "buddy up" a hosted tile service with a hosted feature service. I've published both to AGO. But, what am I missing?

I might expect that when those two are buddies, it might expose a "Query" operation on the Tiled layer. But, that's not happening.

I might expect the Tiled service to have special constructor parameter that allows me to specify the URL for the Dynamic service. But, there's nothing in the documentation.

So, what does it mean to "buddy up" these layers, and how can I take advantage of that to execute a query against the feature data that underlies my tiled layer?
0 Kudos
1 Reply
deleted-user-Jie3eyjOl9XM
Deactivated User
This blog post is one of my initial sources :
http://blogs.esri.com/esri/arcgis/2013/02/19/about-features-and-feature-services/
This is one of the comments:

Eventually I took some training and found how to do this. When you enable a popup on a tile service, it gives you an option to point to a feature service for the popups. The feature service should match the features that were cached in the tile service, of course.

This leads me to believe that the magic is inside the JavaScript API. But that's only useful for a developer who wants the InfoWindow. If we're not using the webmap popup, we have to do something like this:
onclick:
   loop through all layers on the map
      if the layer is a map service 
         if the layer is visible then
            perform an identify
      if the layer is a feature service, or if the layer a tiled service with a feature service url, then
         loop through each layer in the service
            if the layer is in scale then
               perform a query on the layer
   when all of those deferreds return
      normalize the Query results and Identify results into a common format
      do something with the results


Not only is that a lot identifies and queries running asynchronously, but that's a lot of code. How could that possibly be the right way to do this?
0 Kudos