-
-
Notifications
You must be signed in to change notification settings - Fork 40
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
Custom CRS example #31
Comments
In general, it is only possible to manipulate properties from Dash directly, if they can be represented in JSON form. This is not the case for the Therefore, some extra ‘glue’ is needed to translate changes in the Dash prop into changes in the JavaScript object. This is not implemented for the |
I'm looking to choose the Simple CRS without any changes to it
And by registering a client-side callback that runs a function to alter the CRS when the map loads within the Dash app
|
That's a super cool hack! Now that i got around to look at this issue again, i figured that it would actually be rather simple to support the built-in CRS options. I just made a sample implementation, where you simple pass the name as a string to the crs property (i.e. Simple in your case). You can try it here, https://pypi.org/project/dash-leaflet/0.1.2rc2/ Let me know if it works and/or you would prefer a different syntax :) |
Thank-you so much, this is perfect! 🏅 |
Great! I'll add to the next release ;) |
@emilhe I was wondering if the custom CRSs could be implemented by passing the path to a JavaScript function like the GeoJSON |
Yes, that would be an option. It would be more flexible that the current solution (as you could then pass in any CRS), but it would be less user-friendly as it would require the user writing custom JavaScript (as opposed to simply passing a string with the current solution). I haven't used any other CRS than the default myself, so i am not sure if the extra flexibility is needed. Do you have any usecase(s) where the standard CRS object are not sufficient? |
The type of data I'm working with isn't typical for mapping software, as it's not geographical The GeoJSON data I have treats the bottom-left as the origin rather than the top-left |
Ah, i see. In that case, the use of a custom CRS would be neat. I guess it's possible to have the best of both worlds; if a string which is a "normal" coordinate CRS (e.g. "Simple") is provided, that object is created. Otherwise, the string is parsed to a function (which is what you need). I have implemented this approach here, https://pypi.org/project/dash-leaflet/0.1.2rc3/ You would then just provide the path for the function,
and create a .js asset like
The only drawback of this approach is that by allowing arbitrary strings, it becomes possible for the user to get weird error messages if a weird string is provided. Before, the error message was clear since the allowed strings were limited... |
Thanks for being so responsive! It's very appreciated! |
In that case, i think i'll stick with the default-crs-only option. I think it will be easier to use for most people, and i guess it will cover almost all usecases. If you just need to do a simple coordinate flip of the GeoJSON coordintates, i guess you could just set the |
Is there an example of how to specify the crs parameter for non-geographic maps through the python interface?
The snippet of JS code I'm trying to recreate from leaflet is:
Whatever you currently assign to the crs parameter appears to require a function for latLngToPoint
TypeError: "this.options.crs.latLngToPoint is not a function
The text was updated successfully, but these errors were encountered: