Correct use of Find with callback and index

Hi

Could anyone give any pointers on how to use the find method with callback when changing the index when using wheres and whats.

I've implemented a page where you're supposed to be able to navigate through results. When you click e.g. "next results", the index variable is increased by one and the find method fired off again.

The next results button/link is only available when

findResults.HasMore == true

I seem to be getting weird results however. On some wheres and whats I get 1 more pin if I click next. Sometimes I get a lot more but the older pins aren't removed. I tried increasing the index variable by 10 for each click but that isn't the solution.

Any ideas

Cheers

Aled



Answer this question

Correct use of Find with callback and index

  • GSReddy

    i think u need to use map.DeleteAllPushpins() to remove the old pins
  • ImGivingUp

    I'm having trouble figuring out how to get the next page of results as well. I call find with the same input except for the index, but I keep getting the same results back. I'm not sure how FindNearby is supposed to help since the API doesn't suggest I can pass in an index value, or supply a callback function. (I also need to process the info before displaying it) suggestions

  • XNA Rockstar

    OK, so once the user chooses the correct location, the map changes to the new location, right So the next time you call Find(), replace the original "where" parameter with null or the new location, or just call FindNearby() instead of Find(). That should do the trick for you.


  • zdrae

    Ok, thanks for that. Using null seems to work pretty well.

    What I was worried about was that since I zoom in to the map to get a better view of all the returned pushpins, that passing null would return only those results available from the viewable map. Not sure if this is true, but the results seem pretty good.

    I couldn't use FindNearby as I need to use the callback function. Is there a callback function for FindNearby

    Cheers

    Aled


  • KjellSJ

    Ok cool, thats seems to work well.

    What's the best way of storing the user-selected location so that when the user clicks next I don't need to re-ask them to specify their location further

    For example, if the user specifies a location e.g. London which requires them to specify which london they want, they then have to re-specify which london everytime I submit the Find call with a what and where. I don't want to just specify the current map though by passing in null as the where, because I zoom in to encapsulate the current pushpins which may correspond to just a small area of, say, London.

    Any help would be appreciated!

    Thanks

    J


  • chaza

    OK, I've played with FindNearby() for a while now, and it appears to definitely be weird when trying to page through multiple pages of results. However, I think I found a mostly working combination. Here is the behavior I found:

    a) Starting the search with an index of '1' will return any number of results up to 10

    b) Resubmitting FindNearBy() with an index of '2' for the next page will result in mostly duplicate results.

    c) Resubmitting FindNearBy() with an index of 1 greater than the previous number of results returned will result in erratic behavior: Duplicates and no additional results even though HasMore is true.

    d) THE FIX Increment the index by 10 each time you submit FindNearBy(). You may only get 2-3 results, but keep repeating as long as HasMore is true. Doing this prevented duplicates from appearing, and it seemed like I got complete results.

    Can others do some additional testing on this

    One thing I don't understand is why the Search Results for FindNearby() are different than those you get at http://maps.live.com

    For example, why does a maps.live.com search find "Riverside High School", and FindNearBy() does NOT, but finds the school if I enter "Riverside" or "school". (It's just north of Durham, NC near the Eno River Park.)

    Paul Cormier

  • fbecker

    Yes, I think you need to delete the pins (as Yuki Chen suggests) from the first Find() call before calling the second batch.
    As for sometimes seeing 1 more result, and sometimes much more: that's probably because the total number of results that is returned will vary depending on what you are looking for, and where.


  • GMS0012

    Another thing; when I specify an index number in the Find call, should it be + 10 for the next 10 results, or is it the page index so + 1

    Cheers

    Aled


  • Correct use of Find with callback and index