Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MapboxGL Jupyter doesn't sanitise GeoJSON dict before passing it to the JS layer #155

Open
aidanlister opened this issue May 29, 2019 · 3 comments
Labels

Comments

@aidanlister
Copy link

If you pass a GeoJSON dict with single apostrophee's in it, the notebook fails to render the map eg:

{ ... 'properties': {'address': 'foo 'bar'}}
@akacarlyann
Copy link
Collaborator

@aidanlister does your data pass muster with a GeoJSON linter tool? Mapboxgl-jupyter does assume the input data is a valid JSON object, Python dictionary, or DataFrame.

@aidanlister
Copy link
Author

@akacarlyann it's not serialising the data properly when writing it to a file ... it's nothing to do with the input (e.g. an apostrophe in property shouldn't crash the script).

@jdtoy
Copy link

jdtoy commented Apr 20, 2023

Think I've found the bug. Can anyone explain why this line exists? (Paging @perrygeo)

srcdoc = html_data.replace('"', "'")

This is done when building the iframe, after (valid) geojson and html is produced.

The effect is to mangle the geojson in the html.

Property strings which were in the form:

{ ... 'properties': {'address': "someone's place"}}

are converted to being wraped by single quotes:

{ ... 'properties': {'address': 'someone's place'}}

breaking the json, javascript, and map.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants