Browse Source

[enh] new json for embedded map

Laurent Peuch 9 years ago
parent
commit
b5dc44e6e4
2 changed files with 22 additions and 2 deletions
  1. 2 2
      ffdnispdb/templates/site_embed.js
  2. 20 0
      ffdnispdb/views.py

+ 2 - 2
ffdnispdb/templates/site_embed.js

@@ -314,7 +314,7 @@ function init_map() {
     icon_ffdn['options']['iconUrl'] = '../static/img/marker_ffdn.png';
 
     window.isp_list={};
-    $.getJSON('/isp/map_data.json', function(data) {
+    $.getJSON('/isp/map_data_cube.json', function(data) {
         $.each(data, function(k, isp) {
             window.isp_list[isp.id]=isp;
             if(!('coordinates' in isp))
@@ -323,7 +323,7 @@ function init_map() {
             if (!isp.ffdn_member) return;
 
             var marker = L.marker([isp['coordinates']['latitude'], isp['coordinates']['longitude']],
-                                  {'icon': isp.ffdn_member ? icon_ffdn : icon});
+                                  {'icon': isp.distribute_zsh:1: ube ? icon_cube : icon_ffdn});
 
             marker.bindPopup(isp.popup);
             marker.getPopup().on('open', function() {

+ 20 - 0
ffdnispdb/views.py

@@ -70,6 +70,26 @@ def isp_map_data():
     return Response(json.dumps(data), mimetype='application/json')
 
 
+# this needs to be cached
+@ispdb.route('/isp/map_data_cube.json', methods=['GET'])
+def isp_map_data_cube():
+    isps = ISP.query.filter_by(is_disabled=False)
+    data = []
+    for isp in isps:
+        d = dict(isp.json)
+        for k in d.keys():
+            if k not in ('name', 'shortname', 'coordinates'):
+                del d[k]
+
+        d['id'] = isp.id
+        d['ffdn_member'] = isp.is_ffdn_member
+        d['distribute_cube'] = isp.has_technology("cube")
+        d['popup'] = render_template('map_popup.html', isp=isp)
+        data.append(d)
+
+    return Response(json.dumps(data), mimetype='application/json')
+
+
 @ispdb.route('/isp/find_near.json', methods=['GET'])
 def isp_find_near():
     lat = request.args.get('lat')