Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I am creating an Esri Flex API application (not the viewer), and have been creating a tool to use the World Places Locator.

For now, I am just zooming to the top scoring candidate returned.

If you search for Brighton, it returns you 20 candidates, sorted by score.

I read on an older blog post:

You can also filter the results by extent using client logic. The candidates field to look for in this case are North_Lat, South_Lat, East_Lon, and West_Lon. Source.

I am thinking it would be a good idea to have a tickbox on my search, that limits the results to the current extent of the map in the Flex app. (Or maybe buffer a litte out from the view).

I understand the logic on how to go about this, but was wondering if anyone has already done this (does not have to be Flex) so that I can save some time coding it.

If not, I will have a go at this next weekend and post my answer.

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

I have done something similar using C# and LINQ. Basically, I just get the extent from the map, then using LINQ, I queried for the X and Y values that fall within the extent. A crude way to do it would be with if statements. I just googled and found this implementation of linq for ActionScript called ActionLinq:

http://www.srtsolutions.com/introducing%E2%80%A6-actionlinq

So here is some pseudo code without using Linq:

candidatesInExtent = new List;

foreach (candidate in returnedCandidates)
  if(candidate.x > extent.minX || candidate.y > extent.minY)
    if(candidate.x < extent.maxX || candidate.y < extent.maxY)
        candidatesInExtent.add(candidate);
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.