How do i use kepler.gl with Django backend

470 views Asked by At

Is there a kepler library i can install in my django project to use kepler.gl in my frontend, like in leaflet-django. If not, how do i use Kepler.gl maps as frontend for django backend?

2

There are 2 answers

0
hsulso On

You can visit "kepler.gl/demo" and click in the left sidebar export to html. After that you can use this html for your endpoint (view template) in django.

The data can be passed trough the httpResponse in your views.py from the database to view into the script. If you like you can put the script code in seperate Javascript files and link them in your endpoint.

0
Shalaka Deshan On

You can use keplergl module in python. I think this will server your requirement. You can use "from keplergl import KeplerGl " to import it and use something like below code snippet.

from keplergl import KeplerGl 

map_1 = KeplerGl(height=600, config=custom_config)

// Add the data to the map
map_1.add_data(data=data, name="MAP NAME")
map_html =  map_1._repr_html_()

@router.get("/{path}")
async def index():
   return HTMLResponse(content=map_html, status_code=200)