0

Results from query made with other fields are populated on Leaflet:

var myMap = L.map("mapid", {zoomControl: false});
L.tileLayer('https://{s}.tile.openstreetmap.fr/hot/{z}/{x}/{y}.png', {maxZoom: 18 }).addTo(myMap); myMap.setView([-34, 151], 12);
var markers = [
{% for journal in queryset %}
    L.marker([{{ journal.latitude }}, {{ journal.longitude }}]),
{% endfor %}
]
var group = L.featureGroup(markers).addTo(myMap);

I now want the results populated by where the user places Leaflet's boundary box, but I'm bewildered on how to do that. I've got GDAL installed, have converted the long / lat cols to a spatial col in Postgis with ADD COLUMN geom geometry(Point, 4326) GENERATED ALWAYS AS (ST_SetSRID(ST_MakePoint("longitude", "latitude"), 4326)) STORED, added geom = models.PointField(blank=True, null=True) to models.py, but am lost on where to go from here.

This seems the most authoritative tutorial on the topic but I'm totally lost when he gets to views and talks of a generic class based view / list views / Django Rest Framework. Is there a dumbed down explanation somewhere? I feel like an idiot.

Unsure if relevant but the table isn't managed by Django.

1 Answers1

0

Figured it out, although the solution is far more complicated than I initially understood.

This tutorial by the same guy who made the video was helpful. Please see the tutorial as he gives a better explanation than I can.

Also, I couldn't find anything anywhere on installing the PostgreSQL C Client library or what he installs as libpq5 on Win10, but it seems this was unneeded, perhaps because it might already be installed with Postgres.