Android : Only get map markers from database which lie inside a given circle - Google Maps

on Saturday, September 6, 2014


This is a query regarding GoogleMaps API. I am going to make an application which will allow the users to add markers to the map. The coordinates of these markers will be placed in the notifications table in my database.


Now the application functions in a way that I want to show only those markers to the user which may lie inside a user defined circular area.


Do I have to load all the data ( Json string of all notification marker coordinates) and then iterate through them to place only those markers which are in the current view or selected circular area? Is there an efficient way to return only those markers which would lie inside the given circular area or currently selected viewport?


What if the database contains thousands of markers and the currently selected circular area contains only one marker in my notifications table. DO I have to iterate through all those thousands of coordinated and then check if they lie inside the circle? Isnt there a way through which I could select only those points which would lie inside the given circle. Like some type of hash value for each marker which would match with the given circular area?


I am new to Google maps API. I am aware of MarkerClusterer but I think MarkerClusterer would get all the markers coordinates even if I have to show only one marker inside the desired circular area. What might be the possible solution to this problem.


0 comments:

Post a Comment