Skip to content

Commit

Permalink
don't require nextzen API key if serving locally
Browse files Browse the repository at this point in the history
  • Loading branch information
thisisaaronland committed Jun 2, 2021
1 parent 77c18da commit 266ee00
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 deletions.
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,8 @@ cli:
debug:
go run -mod vendor cmd/server/main.go -nextzen-apikey $(APIKEY) -enable-placeholder -placeholder-endpoint $(SEARCH) -enable-oembed -oembed-endpoints 'https://millsfield.sfomuseum.org/oembed/?url={url}&format=json' -enable-writer

debug-tilepack:
go run -mod vendor cmd/server/main.go -enable-tilezen-tilepacks -tilezen-path-tilepack $(TILEPACK) -nextzen-tile-url 'http://localhost:8080/tilezen/vector/v1/512/all/{z}/{x}/{y}.mvt' -enable-oembed -oembed-endpoints 'https://millsfield.sfomuseum.org/oembed/?url={url}&format=json' -enable-writer

debug-protomaps:
go run -mod vendor cmd/server/main.go -map-renderer protomaps -protomaps-tile-url $(TILES) -enable-oembed -oembed-endpoints 'https://millsfield.sfomuseum.org/oembed/?url={url}&format=json' -enable-writer -writer-uri exif://
2 changes: 1 addition & 1 deletion app/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ func AppendTilezenFlags(fs *flag.FlagSet) error {

fs.Bool("enable-tilezen-tilepacks", false, "Enable to use of local Tilezen MBTiles database.")
fs.String("tilezen-path-tilepack", "", "A valid path for a local Tilezen MBTiles database.")
fs.String("tilezen-url-tiles", "/tilezen", "The URL (a relative path) for serving local Tilezen MBTiles database.")
fs.String("tilezen-url-tiles", "/tilezen/", "The URL (a relative path) for serving local Tilezen MBTiles database.")

// https://github.com/sfomuseum/go-http-tilezen

Expand Down
23 changes: 19 additions & 4 deletions static/javascript/geotag.maps.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,17 +93,32 @@ geotag.maps = (function(){
}

if (map_renderer == "tangramjs"){

// If we don't have an API key check to see if we're serving tiles locally

if (! args["api_key"]){
return null;

var tile_url = args["tile_url"];

var proto = location.protocol;
var host = location.host;
var test = proto + "//" + host;

if (! tile_url.startsWith(test)){
console.log("Missing Nextzen API key and tile URL is not local server");
return null;
}

// Tangram.js expects an API key even if it's bunk
args["api_key"] = "local";
}

var api_key = args["api_key"];

var tangram_opts = self.getTangramOptions(args);
var tangramLayer = Tangram.leafletLayer(tangram_opts);

tangramLayer.addTo(map);

map.setMaxZoom(17); // really?
}

var attribution = self.getAttribution(map_renderer);
Expand Down Expand Up @@ -144,7 +159,7 @@ geotag.maps = (function(){
url_subdomains: ['a', 'b', 'c', 'd'],
url_params: {api_key: api_key},
tile_size: 512,
max_zoom: 18
max_zoom: 18,
}
}
}
Expand Down

0 comments on commit 266ee00

Please sign in to comment.