diff --git a/apps/map/templates/map/index.html b/apps/map/templates/map/index.html index 498d647..f57edbb 100644 --- a/apps/map/templates/map/index.html +++ b/apps/map/templates/map/index.html @@ -5,116 +5,159 @@ {% load static %} {% block stylesheets %} - {{ block.super }} - {% leaflet_css %} - -{% endblock %} +{{ block.super }} +{% leaflet_css %} + +{% endblock %} {% block title %}{% trans "Ojuso Platform Map" %}{% endblock %} - {% block inner_content %}
-
+
{% endblock %} - {% block scripts %} - {% leaflet_map "main" callback="main_app_init" creatediv=False %} - {% leaflet_js %} - - + +// This is called when the map is initialized +function main_app_init(map, options) { + var hash = new L.hash(map); + + // Pull data as GeoJSON and add to map with a modal + $.getJSON('/api/case-studies/', function(data) { + L.geoJson(data, { + onEachFeature: popup + }).addTo(map) + }); +} + + {% endblock %} + + \ No newline at end of file diff --git a/ojusomap/urls.py b/ojusomap/urls.py index 6bf7217..4abb649 100644 --- a/ojusomap/urls.py +++ b/ojusomap/urls.py @@ -34,10 +34,24 @@ class UserViewSet(viewsets.ModelViewSet): class CaseStudySerializer(gis_serializers.GeoFeatureModelSerializer): + sector_of_economy = serializers.CharField(source='get_sector_of_economy_display') + country_name = serializers.CharField(source='get_country_display') + positive_or_negative_display = serializers.CharField(source='get_positive_or_negative_display') + class Meta: model = CaseStudy geo_field = "location" - fields = '__all__' + fields = ( + 'country', + 'country_name', + 'entry_name', + 'image', + 'location', + 'positive_or_negative', + 'positive_or_negative_display', + 'sector_of_economy', + 'slug' + ) class CaseStudyViewSet(viewsets.ModelViewSet):