Server Side Google Markers Clustering - Python/Django

前端 未结 5 1088
一整个雨季
一整个雨季 2021-02-06 09:18

After experimenting with client side approach to clustering large numbers of Google markers I decided that it won\'t be possible for my project (social network with 28,000+ user

相关标签:
5条回答
  • 2021-02-06 09:32

    One way to do it would be to define a grid with a unit size based on the zoom level. So you collect up all the items within a grid by lat,lon to one decimal place. An example is 42.2x73.4. So a point at 42.2003x73.4021 falls in that grid cell. That cell is bounded by 42.2x73.3 and 42.2x73.5.

    If there are one or more points in a grid cell, you place a marker in the center of that grid.

    You then hook up the zoomend event and change your grid size accordingly, and redraw the markers.

    http://code.google.com/apis/maps/documentation/reference.html#GMap2.zoomend

    0 讨论(0)
  • 2021-02-06 09:36

    This is a paid service that uses server-side clustering, but I'm not sure how it works. I'm guessing that they just use your data to generate the markers to be shown at each zoom level.

    Update: This tutorial demonstrates a basic server-side clustering function. It's written in PHP for the Static Maps API, but you could use it as a starting point.

    0 讨论(0)
  • 2021-02-06 09:38

    I am using Django and Python to cluster real estate and rental listings, and the source can be found here.

    Hope it helps!

    0 讨论(0)
  • 2021-02-06 09:39

    You might want to take a look at the DBSCAN and OPTICS pages on wikipedia, these looks very suitable for clustering places on a map. There is also a page about Cluster Analysis that shows all the possible algorithms you can use, most would be trivial to implement using the language of your choice.

    With 28k+ points, you might want to skip django and just jump into C/C++ directly, and surely not expect this to get calculated in real-time in response to web requests.

    0 讨论(0)
  • 2021-02-06 09:49

    You can try my server-side clustering django app:

    https://github.com/biodiv/anycluster

    It prvides a kmeans and a grid cluster.

    0 讨论(0)
提交回复
热议问题