javascript - Unable to show google map marker clusters in Geodjango -


i add google map marker clusters in geodjango app.i have 16,000 user locations want use google map markers in google map api 3. however, presumably due large json file (5mb) represents serialized version of django models geoqueryset objects, takes 3.6 minutes (and counting) load markers (actually, markers did not load, marker script gives 200 status message). know options have load json file faster , render markers efficiently. have learnt 656x faster json parsing in python possible ijson (here). json data served javascript file (map.js), wonder how can load markers faster, or load them.

i have limited knowledge in javascript/jquery. json variable contains fields 'nickname' , 'last_location', in last_location field marker field. missing in map.js file loads google map fails load markers? can please suggest solution?

the map.js:

function initmap(){     var mapdiv = document.getelementbyid('map');     var latlng = new google.maps.latlng(8.9806, 38.7578);     var southwest=new google.maps.latlng(8.834544,38.640241);     var northeast=new google.maps.latlng(9.099231,38.907086);     var bounds = new google.maps.latlngbounds(southwest,northeast);          var options = {         center: latlng,         zoom: 17,         maptypeid: google.maps.maptypeid.roadmap         };     var map = new google.maps.map(mapdiv,options);      map.fitbounds(bounds);      //labels markers     var labels = 'abcdefghijklmnopqrstuvwxyz';       var json = "http://127.0.0.1:8080/my_endpoint";        var markers=[];     (var = 0; < json.length; i++) {         var marker = new google.maps.marker({             position: new google.maps.latlng(json[i][0], json[i][1]),             map: map         });      google.maps.event.addlistener(marker, 'click', (function(marker, i) {         return function(initmap) {             infowindow.setcontent(json[i][0]);             infowindow.open(map, marker);     }   })(marker, i));   markers.push(marker); } var mc = new markerclusterer(map, markers);       }  

the cmd console output:

performing system checks...

system check identified no issues (0 silenced). september 10, 2017 - 13:53:21 django version 1.11.3, using settings 'aamap_project.settings' starting development server @ http://127.0.0.1:8080/ quit server ctrl-break.   ...{"model": "mymap_app.lovefinderuser", "pk": 16164, "fields": {"nicknam e": "7300de79-af15-4b75-85a1-1e50552c22f5", "age": 40, "sex": "f", "prefered_sex ": "m", "prefered_age_min": 35, "prefered_age_max": 41, "last_location": "srid=4 326;point (38.76450215958042 8.926138069213579)", "prefered_radius": 30}}, {"mod el": "mymap_app.lovefinderuser", "pk": 16165, "fields": {"nickname": "419c5e3c-6 075-4eb4-9af0-97692743e9f6", "age": 23, "sex": "m", "prefered_sex": "m", "prefer ed_age_min": 20, "prefered_age_max": 24, "last_location": "srid=4326;point (38.7 5264058885222 8.900623973521471)", "prefered_radius": 5}}, {"model": "mymap_app. lovefinderuser", "pk": 16166, "fields": {"nickname": "5071dd02-4437-46d3-81a6-1b fed7a0962b", "age": 33, "sex": "m", "prefered_sex": "m", "prefered_age_min": 30,  "prefered_age_max": 34, "last_location": "srid=4326;point (38.79797126416635 8. 998704662589962)", "prefered_radius": 5}}, {"model": "mymap_app.lovefinderuser",  "pk": 16167, "fields": {"nickname": "93f308d3-61bf-4693-9f8d-816ecd0c2bd4", "ag e": 47, "sex": "f", "prefered_sex": "m", "prefered_age_min": 39, "prefered_age_m ax": 48, "last_location": "srid=4326;point (38.74743090479093 8.877994804401524) ", "prefered_radius": 5}}, {"model": "mymap_app.lovefinderuser", "pk": 16168, "f ields": {"nickname": "31a76bb0-0567-4ef2-a022-64ad5302998b", "age": 37, "sex": " f", "prefered_sex": "f", "prefered_age_min": 29, "prefered_age_max": 39, "last_l ocation": "srid=4326;point (38.66436345369468 8.867450881027496)", "prefered_rad ius": 5}}] size of json is: 4913395 [13/sep/2017 20:19:00] "get /my_endpoint/ http/1.1" 200 5430748 

the views.py:

class myview(view):  def get(self, request):     data = serializers.serialize("json", userlist.objects.all().only('nickname','last_location'))     print(data)     print("the size of json is:", sys.getsizeof(data))     return jsonresponse(data,safe=false,content_type="application/json", charset="utf-8") 


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -