2

I'm working on a mobile app, and I would like to implement a feature that allows users to search for nearby stores that are participating in our program. We have a nationwide network, so for the sake of simplicity I'd like to do something like show them the stores within X miles of their location, limiting to the N closest if there are too many.

So far I've got test tables up and running, and I've created test map layers, and all of that is going well. I'm able to query my tables and get lists of stores matching my criteria, and that seems to be working smoothly too.

My question is, is there a good way to go from a list of stores selected with a call like

GET .../tables/TABLE_ID/features?where=SEARCH_CRITERIA&key=KEY

to a set of points overlaid on a map?

It seems to me that the only way to do this within the API is to make the request, write the data to a file, re-upload that file to create a new table, use that table to create a new layer, and finally overlay the new layer. But I find it hard to believe that there isn't a better way to do what I want to do.

Is there an easier way that I'm missing in the documentation? Or some other solution out there? Is there another tool besides Maps Engine that would be better suited?

stranger
  • 390
  • 4
  • 17

1 Answers1

2

If you're building a web or hybrid app, you can use the Maps JavaScript API, particularly with the Data Layer. The key thing to understand is that the feature list API call in the Maps Engine API returns data in GeoJSON format and the data layer accepts GeoJSON data, either as a pure JSON object or as a URL that returns GeoJSON (i.e. a Maps Engine API call).

Unfortunately with Android, there is no data layer equivalent. The good news is that (for point data at least) it is still quite simple to add your own markers. You will need to:

  1. Execute the GET query you listed in your post to return a JSON response.
  2. Iterate over the response data, specifically over the features array returned at the top level.
  3. For each feature, add a Marker to your map.

There is also a Java client for Maps Engine that you could use in your app to make steps 1 & 2 a bit simpler.

Mark McDonald
  • 7,571
  • 6
  • 46
  • 53
  • Thank you. I hadn't thought about the possibility of querying the MapsEngine table/.../feature API and then using that data to place regular Maps markers. That's a very straightforward approach. – stranger Jul 30 '14 at 15:09