0

I've written a Python function to open a geojson.io page with JSON data following these instructions.

My function works fine but, when I call it, I can't stop the right info sidebar (the bar that shows the JSON data) from appearing.

Is there a way to tell the geojson.io server not to show that sidebar?

My code:

import json
from urllib.parse import quote
import webbrowser

def view_trajectory(json_data):
    """Open a geojson.io map showing the trajectory specified."""
    stringified = json.dumps(json_data)
    url = "http://geojson.io/#data=data:application/json," + quote(stringified)
    print("url:", url, sep="\n")
    webbrowser.open(url)

Sample JSON data:

{
  "type": "Feature",
  "properties": {
    "title": "Trajectory",
    "stroke": "#ff0000",
    "stroke-width": 4
  },
  "geometry": {
    "coordinates": [
      [
        -3.4792972406776244,
        41.3159281332415
      ],
      [
        -3.4786137899426706,
        41.31580543727685
      ]
    ],
    "type": "LineString"
  }
}

which produces this URL.

Partial image showing the sidebar that hinders me

I've tried adding things like &hide-inspector, embed=true or sidebar=none to the URL but nothing works.

jonrsharpe
  • 115,751
  • 26
  • 228
  • 437

0 Answers0