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

mapzen.js doesn't load with requirejs #382

Open
marianoguerra opened this issue May 5, 2017 · 3 comments
Open

mapzen.js doesn't load with requirejs #382

marianoguerra opened this issue May 5, 2017 · 3 comments

Comments

@marianoguerra
Copy link

here's a minimal example:

http://marianoguerra.github.io/bugs/mapzen-requirejs/

you can see the code here:

https://github.com/marianoguerra/marianoguerra.github.io/blob/master/bugs/mapzen-requirejs/app.js

looking at the code in mapzen.js you call define(['leaflet'], factory) in line 1236 but leaflet is defined in line 1836 as define(L) (which I think it should be define('leaflet', L))

I tried using mapzen.standalone.min.js instead and loading my leaflet:

https://github.com/marianoguerra/marianoguerra.github.io/blob/master/bugs/mapzen-requirejs/app.standalone.js

but as you can see here, it complains that "ReferenceError: Tangram is not defined":

http://marianoguerra.github.io/bugs/mapzen-requirejs/standalone.html

reading the code, I passed _useTangram: false in options but then it renders a gray map and never request the tiles.

my code was working with leaflet and osm tiles, can I set mapzen tiles url template, api key and attribution directly on leaflet? is there something else I have to do?

@marianoguerra
Copy link
Author

this line seems to assume that _importScript will register Tangram in the global scope:

https://github.com/mapzen/mapzen.js/blob/master/src/js/components/tangram.js#L61

but with requirejs it doesn't, I did another example where I load tangram before and put it in the global scope here:

http://marianoguerra.github.io/bugs/mapzen-requirejs/standalone-manual-tangram.html

code here https://github.com/marianoguerra/marianoguerra.github.io/blob/master/bugs/mapzen-requirejs/app.standalone.manual.tangram.js

@marianoguerra
Copy link
Author

now I did the standalone.manual.tangram thing and it works during development but on production in firefox (nightly) it fails, it seems to be because of this: tangrams/tangram#252

Tangram v0.12.4 [error]: Scene.load() failed to load https://mapzen.com/carto/bubble-wrap-style-more-labels/7/bubble-wrap-style-more-labels.zip: There was a network error[object ProgressEvent] Error: There was a network error[object ProgressEvent]

@rfriberg
Copy link
Contributor

rfriberg commented May 8, 2017

Hi @marianoguerra - thanks for the report.

That Tangram issue you pointed to has long been a blocker for bundling Tangram within mapzen.js. But we're now close to being able to import Tangram as a node module and require it in a way that will work with your examples.

At the moment, you can load your own versions of leaflet and Tangram - tangrams/tangram-frame currently does this. But keep in mind that if you go this route, Leaflet and Tangram should be considered dependencies of mapzen.js. I believe explicit dependencies can be set in requirejs by using the shim config.

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