0

Hi Stackoverflow people,

I started using GeoDjango and I was very happy when I came across the Google map v2 implementation django.contrib.gis.maps.google.overlays. Not the newest anymore, since v2 is depreciated, but still a very compact tools to simply display markers on a map with

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
{{ google.xhtml }}
<head>
  {{ google.style }}
  {{ google.scripts }}
</head>
<body onload="{{ google.js_module }}.map_load()" onunload="GUnload()">
  <div id="{{ google.dom_id }}" style="width:600px; height:400px;"></div>
</body>
</html>

Code taken from here.

Based on this very compact code, how can I implement a clustering function? I have read that clustering is not supported by GeoDjango at the moment. Has anyone implemented clustering by using the django.contrib.gis.maps.google.overlays? Or is it the better way to write the full function myself and loop through all list entries to create the markers?

Thank you for sharing your experience and suggestions.

Has QUIT--Anony-Mousse
  • 76,138
  • 12
  • 138
  • 194
neurix
  • 4,126
  • 6
  • 46
  • 71
  • 1
    kmeans is the common method used for clustering, do a search for that here. You'll probably need to implement your own view taking into account a bbox and zoomlevel. – monkut May 31 '12 at 12:52
  • I *dont* understand why this is voted down. – Shayne Jan 28 '20 at 01:52

1 Answers1

4

You can try my geodjango clustering app for server-side clustering:

https://github.com/biodiv/anycluster

It uses kmeans and/or grid.

biodiv
  • 607
  • 6
  • 16
  • Interesting stuff. I wrote something like that in C++ and use it as a command line utility from inside web apps, but now that I think of it doing it in the database seems more appropriate and scalable. Thanks for sharing! – adonig Aug 01 '22 at 12:10