Skip to content
This repository has been archived by the owner on Feb 23, 2023. It is now read-only.

Commit

Permalink
Fix failure rendering styles that use glyphs or sprites (#4)
Browse files Browse the repository at this point in the history
* Log requests for invalid protocols

* Update to mapbox-gl-native 5.0.2

* Bump version to 0.0.4

* Fix styles with glyphs and sprites not working

* Update getMap.js

Co-Authored-By: John J Czaplewski <[email protected]>

Co-authored-by: John J Czaplewski <[email protected]>
  • Loading branch information
Jesse Crocker and jczaplew authored Mar 27, 2020
1 parent 8da41d8 commit bdabc36
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 61 deletions.
6 changes: 5 additions & 1 deletion getMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ function getMap() {
mode: "static",
ratio: 1.0,
request: function(req, callback) {
debug("request: " + JSON.stringify(req));
var start = Date.now();
var protocol = req.url.split(":")[0];
if (protocol == "file") {
Expand All @@ -29,7 +30,7 @@ function getMap() {
callback(null, response);
debug("Request for " + req.url + " complete in " + (Date.now() - start) + "ms");
});
} else {
} else if (protocol === "http" || protocol === "https") {
request(
{
url: req.url,
Expand Down Expand Up @@ -79,6 +80,9 @@ function getMap() {
}
}
);
} else {
debug(`request for invalid url: "${req.url}"`);
return callback(`request for invalid url: "${req.url}"`);
}
}
});
Expand Down
2 changes: 2 additions & 0 deletions mapUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ exports.calculateZoom = function(extent, width, height) {

exports.addOverlayDataToStyle = function(style, overlay) {
return {
glyphs: style["glyphs"] || "",
sprints: style["sprites"] || "",
sources: {
...style["sources"],
overlay: { type: "geojson", data: overlay }
Expand Down
128 changes: 70 additions & 58 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "StaticMaps-gl",
"version": "0.0.3",
"version": "0.0.4",
"description": "Static map rendering with mapbox-gl",
"keywords": [],
"main": "./index.js",
Expand All @@ -10,7 +10,7 @@
},
"license": "BSD-2-Clause",
"dependencies": {
"@mapbox/mapbox-gl-native": "^4.1.0",
"@mapbox/mapbox-gl-native": "^5.0.2",
"@mapbox/sphericalmercator": "^1.1.0",
"@turf/bbox": "^6.0.1",
"debug": "^4.1.1",
Expand Down

0 comments on commit bdabc36

Please sign in to comment.