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

Can't get plugin to work w/ non-MapBox TileJSON file #11

Open
jameslaneconkling opened this issue Aug 14, 2014 · 8 comments
Open

Can't get plugin to work w/ non-MapBox TileJSON file #11

jameslaneconkling opened this issue Aug 14, 2014 · 8 comments

Comments

@jameslaneconkling
Copy link

Been trying to get this plugin to work w/ my own TileJSON reference but am getting the following error:

[tilemill] Client Error: Script error.
[tilemill]     at :0
[tilemill] Client Error: TypeError: 'undefined' is not an object (evaluating 'a.tiles')
[tilemill]     at http://127.0.0.1:20009/assets/tilemill/js/vendor.js:5164

My TileJSON definition is hosted here, which is CORS supported.

I did have luck using the TileJSON url w/ mapbox.js, so I don't think it's an error w/ the definition. And the plugin did work with a MapBox TileJSON url (tried with this). Any thoughts?

Really useful plugin--allows me to style transparent data overlay layers on top of my base layer w/o having to define the whole baselayer w/i the data overlay project. Thanks.

@springmeyer
Copy link
Contributor

not sure. couple (untested) ideas: 1) maybe another plugin is conflicting - try uninstalling other plugins, or 2) maybe the code in this plugin is not detecting that you are using a custom tilejson url (try adding some print statements to the code like right here to see if that is getting invoked).

@jameslaneconkling
Copy link
Author

I uninstalled all other plugins, but the problem persists.

started digging around in the Map.bones file you suggested. I'm not much of a developer, but familiar enough with js to get much (or some) of what's going on. If I tried to debug where you suggested, what would I use to print messages to the console?

Thanks for the help, of course.

@jameslaneconkling
Copy link
Author

Ah, console.log() seems to work, but only when defined outside of the function assigned to view.prototype.render.

@springmeyer
Copy link
Contributor

console.log() yes, just realize that depending on where it is you might need to check the tilemill console/logs and/or your browsers debug: http://debugbrowser.com/

@pakore
Copy link

pakore commented Sep 5, 2014

Did you get it to work? I got the same error.

@jameslaneconkling
Copy link
Author

not yet. spent some time trying to debug, but couldn't pinpoint.

(in the meantime, I've just uploaded a small version of the map to mapbox).

On Fri, Sep 5, 2014 at 11:31 AM, pakore notifications@github.com wrote:

Did you get it to work? I got the same error.


Reply to this email directly or view it on GitHub
#11 (comment)
.

@pakore
Copy link

pakore commented Sep 11, 2014

I did a workaround (I removed my urls since they are internal)

diff --git a/views/Map.bones b/views/Map.bones
index ff05079..4197b49 100644
--- a/views/Map.bones
+++ b/views/Map.bones
@@ -40,6 +40,26 @@ view.prototype.render = function(init) {
     // Indentify which layer is the TileMill layer
     this.map.tmLayer = 0;

+var tilejson_base = {
+  tilejson: '1.0.0',
+  scheme: 'xyz',
+  tiles: ['your_base_url_here'],
+  "minzoom": 0,
+  "maxzoom": 20
+};
+var tilejson_labels = {
+  tilejson: '1.0.0',
+  scheme: 'xyz',
+  tiles: ['your_labels_url_here'],
+  "minzoom": 0,
+  "maxzoom": 20
+};
+
+
+this.map.insertLayerAt(0, new wax.mm.connector(tilejson_base));
+this.map.insertLayerAt(2, new wax.mm.connector(tilejson_labels));
+this.map.tmLayer=1;
+/*
     // Get remote map endpoint
     var basemap = (this.model.get('_basemap'));
     if (basemap) {
@@ -49,14 +69,13 @@ view.prototype.render = function(init) {
         if (basemap.match(/^[^/.]+\.[^/.]+$/)) {
             basemap = this.model.mapboxTileJSON(basemap);
         }
-
         wax.tilejson(basemap, _(function(tilejson) {
             // Insert remote map as a layer
             this.map.insertLayerAt(0, new wax.mm.connector(tilejson));
             this.map.tmLayer = 1; // Indicate that the TileMill layer has changed
         }).bind(this));
     }
-
+*/

@jameslaneconkling
Copy link
Author

Ran into something similar using mapbox.js and will record here in case it's of use to anyone. Have a hunch that the problem here is w/ retina displays:

  • L.mapbox.tileLayer(layerJSON) appends @2x to tile urls automatically, which obviously won't work w/ tileservers not configured to generate 2x tiles.
  • here's a js fiddle recreating the problem w/ mapbox.js.

@pakore 's workaround to hardcode the tile url templates is a good fix. Thanks.

don't have access to a non-retina display at the moment, so can't fully verify. will post when I do.

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

No branches or pull requests

3 participants