Search code examples
androidandroid-mapviewprojection

Get android's MapView Projection's last state


I have two activities one displaying map view and another listview, the main objective is both should remain in sync in respect to the data displayed by both of them.

POIs displayed on map should get displayed on list and vice versa. The problem is, i have a feature called "search area" in tht i search in a map center (150 miles around) and display results only which are visible in currently displayed area of map view. now on map view its working fine and on list view too its working fine if i dont move the map around after POIs has been displayed.

As i am using Projection from map view to get the x,y of items, so when i move the map and switch to list view it gets the list of items and starts finding the x,y of the items but as map has been moved there are some items which can either be added or removed to the listview just because i moved the map and now projection is returning the new x,y for the items which falls under current display area.

but in idle situation i should only display those items in list view which were displayed in mapview. for. e.g there were 2 items that were displayed in a particular area displayed on a map, now i moved around in the map and just switched to list view now list view will fetch a new list from the server and would try to find their x,y from mapview's projection but it will include/exclude few items according to the new map state.

how to get the initial state of the mapview's projection (at the point when i was displayed the original items) so that i can display the same item list again.

i know its bit specific to app logic but still i just want to get the map views projection initial state.

Thanks in advance


Solution

  • I am answering my own question, this thing is not possible in Android, as Android MapView is singleton in implementation, no matter how many mapview objects you have they will share same internal variables (for e.g. Projection, it will get updated as soon as you update a map view, so that moving to the previous mapview will display the same projection state of the one from which you just switched.) across the application.