0

My question is, What is the best way to set to many markers on google maps on android program? I have a sqlite database with longitude and latitude for every markers.

  1. For example add all markers 1km around the current location
  2. Get the range of longitude and latitude on moving map and display markers between that range

How can i get the range of longitude and latitude?

Siddharth
  • 9,349
  • 16
  • 86
  • 148
petar.bt
  • 13
  • 4
  • If you could add a bit more clarity regarding what the problem is. Are you asking how to plot lots of markers and the most efficient way to do this? OR Are you asking for alternatives to plotting every marker on a map? – Peter Brooks Dec 13 '11 at 00:35
  • I'm making some program for bus traveling.I have a database of about 600 points of latitude and longitude where the buses stop. I want to plot all that points on GoogleMaps.If a plot all that markers at the same time the application will be very slow. I'm asking how to plot all that markers on the most efficient way. For example one user with currently location in America ( for example ) is not interesting about the markers from Europe. My first idea is print all markers around 1km of the current user location to prevent not to plot markers that for the user not see on the map or isn't useful. – petar.bt Dec 13 '11 at 21:01

1 Answers1

0

Based on the comments from above you will need to do the following:

1) Use the Google Api maps reference for Android to determine the visible area on the map and if one of your points is within the determined area.

2) Carefully remove points added to the map but which are no longer needed. (IE the user has moved the map). Be careful at this point not to remove a point before the map has finished updating, as the user could tap on a point and crash the app.

3) Decide what you're doing about zoom level, if a user zooms right out then you need to do one of the following:

a) Display nothing, give the user feedback to zoom in for points. b) Use an algorithm to plot a point at an average of a point. c) Display a marker as with b but centered in a region with the number of points in that region.

I would advise lots of research on stack regarding previous questions as this topic has been covered in some detail.

For c) there has been a good iOS implementation which is now a for-sale library, however the name of the library escapes me at the moment. I am told the implementation is excellent.

I cannot express enough that you need to make sure your map operations are done asynchronously, be wary of this or fall into lots of traps.

Community
  • 1
  • 1
Peter Brooks
  • 1,170
  • 9
  • 23
  • I decide to use Google Maps API3 using JavaScript and WebView. I get the bounds using JavaScript ( var bounds = map.getBounds(); ). Than I get ( var ne = bounds.getNorthEast(); ) and ( var sw = bounds.getSouthWest(); ) and than .lat() and .lng() from both variable and i send this variable to db query, but its not working. Is query correctly? Cursor cursor = this.db.rawQuery("SELECT * FROM town WHERE town_lat>= " + SwLat + " AND town_lat<= " + NeLat + " AND town_lon>= " + SwLng + " AND town_lon<= " + NeLng, null); – petar.bt Jan 10 '12 at 15:16