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

Exposing the map object for Javascript plugins #1166

Closed
codeZeilen opened this issue Feb 27, 2016 · 4 comments
Closed

Exposing the map object for Javascript plugins #1166

codeZeilen opened this issue Feb 27, 2016 · 4 comments

Comments

@codeZeilen
Copy link

Hello everyone,

In order to add some more tools to the OSM page (mostly measuring), I starting building a Chrome browser extension. However, I was quickly stopped by the fact that the leaflet map object is closured in the individual OSM modules. Thus, it can not be referenced and modified by external scripts. In favor of making the page easier to extend, I would like to propose that the page exposes the map object to other scripts.

I am not too familiar with the conceptual architecture of the Javascript modules beyond what is apparent from the source. From that perspective however, I would propose adding the map object to the global OSM object during the setup in openstreetmap-website/app/assets/javascripts/index.js.

BTW: Thanks for all your great work on OSM :)

@tomhughes
Copy link
Member

I believe we have already refused this in the past.

Certainly I have no wish to expose any sort of API in this way - if anything my goal is to eliminate all global scope variables in our javascript.

Consider this - if we had done this back when we were using OpenLayers what sort of screams of protest would there have been when we switched to Leaflet and everything broken because our "API" had changed? That's why I don't want to codify anything here.

@codeZeilen
Copy link
Author

Yes, I do get that point. So that means, there is currently no way to extend the interface from the outside, am I correct? What are the chances of getting anything like "Show the geoposition on mouse click" and simple measuring for lines or areas (as supported by some leaflet plugins) into the master? If there is interest, I might invest the time and integrate these features properly.

@tomhughes
Copy link
Member

Our position has always been that we don't want the web site to become an end user destination site, so any tools need to be of use for mapping, not just to a user.

@codeZeilen
Copy link
Author

Ok :) Thanks for your quick answers!

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

No branches or pull requests

2 participants