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

Commit bdabc36

Browse files
Jesse Crockerjczaplew
andauthored
Fix failure rendering styles that use glyphs or sprites (#4)
* 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 <john@gaiagps.com> Co-authored-by: John J Czaplewski <john@gaiagps.com>
1 parent 8da41d8 commit bdabc36

File tree

4 files changed

+79
-61
lines changed

4 files changed

+79
-61
lines changed

getMap.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ function getMap() {
1616
mode: "static",
1717
ratio: 1.0,
1818
request: function(req, callback) {
19+
debug("request: " + JSON.stringify(req));
1920
var start = Date.now();
2021
var protocol = req.url.split(":")[0];
2122
if (protocol == "file") {
@@ -29,7 +30,7 @@ function getMap() {
2930
callback(null, response);
3031
debug("Request for " + req.url + " complete in " + (Date.now() - start) + "ms");
3132
});
32-
} else {
33+
} else if (protocol === "http" || protocol === "https") {
3334
request(
3435
{
3536
url: req.url,
@@ -79,6 +80,9 @@ function getMap() {
7980
}
8081
}
8182
);
83+
} else {
84+
debug(`request for invalid url: "${req.url}"`);
85+
return callback(`request for invalid url: "${req.url}"`);
8286
}
8387
}
8488
});

mapUtils.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ exports.calculateZoom = function(extent, width, height) {
6060

6161
exports.addOverlayDataToStyle = function(style, overlay) {
6262
return {
63+
glyphs: style["glyphs"] || "",
64+
sprints: style["sprites"] || "",
6365
sources: {
6466
...style["sources"],
6567
overlay: { type: "geojson", data: overlay }

package-lock.json

Lines changed: 70 additions & 58 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "StaticMaps-gl",
3-
"version": "0.0.3",
3+
"version": "0.0.4",
44
"description": "Static map rendering with mapbox-gl",
55
"keywords": [],
66
"main": "./index.js",
@@ -10,7 +10,7 @@
1010
},
1111
"license": "BSD-2-Clause",
1212
"dependencies": {
13-
"@mapbox/mapbox-gl-native": "^4.1.0",
13+
"@mapbox/mapbox-gl-native": "^5.0.2",
1414
"@mapbox/sphericalmercator": "^1.1.0",
1515
"@turf/bbox": "^6.0.1",
1616
"debug": "^4.1.1",

0 commit comments

Comments
 (0)