cutting-room-floor / tilemill-reference-layer

TileMill Plugin that allows adding a tiled layer from tiles.mapbox.com
14 stars 7 forks source link

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

Open jameslaneconkling opened 10 years ago

jameslaneconkling commented 10 years ago

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 commented 10 years ago

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 commented 10 years ago

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 commented 10 years ago

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

springmeyer commented 10 years ago

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 commented 10 years ago

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

jameslaneconkling commented 10 years ago

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 https://github.com/mapbox/tilemill-reference-layer/issues/11#issuecomment-54640562 .

pakore commented 10 years ago

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 commented 9 years ago

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:

@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.