How to load markers dynamically for current position in Android google-maps?

前端 未结 4 1512
野性不改
野性不改 2021-02-04 20:39

I\'m currently developing an app for Android which uses google map service. Because users will be able to see thousands of markers I would like to load only those which are curr

4条回答
  •  逝去的感伤
    2021-02-04 21:20

    Where are those place-marks coming from? If they are coming from a web service, check if the web service supports spatial queries. If its a basic point in extent (rectangular envelope) you could do something like this:

    Note: (xmin, ymin -> xmax, ymax) are the bounds of your rectangle (extent).

    def is_point_in_rect(px, py, xmin, ymin, xmax, ymax):
      if px >= xmin and px <= xmax:
        if py >= ymin and py <= ymax:
          return True
      else:
        return False
    

    This is something very simple. You can even use the Google Maps Data API to store your place-marks and that has a mechanism to execute spatial queries.

    If your data is on Google App Engine, then you could use GeoPt based queries or you could roll your own spatial index. Check out http://code.google.com/p/geomodel/

提交回复
热议问题