Skip to content

Commit 1460e0f

Browse files
committed
Fix vectorserverUrl not returning image
1 parent 34b9b41 commit 1460e0f

File tree

8 files changed

+27
-13
lines changed

8 files changed

+27
-13
lines changed

CHANGELOG.md

+7
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
# 4.0.1
2+
3+
Fix vectorserverUrl
4+
5+
- Fix vectorserverUrl option was never returning the image
6+
- Change equal default zoom for vector and raster tiles
7+
18
# 4.0.0
29

310
Change commonjs to nodejs modules

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ All parameters have a short and long version. The short version can be used only
6969
| H | height | height in pixels of the returned img | `600` |
7070
| W | width | height in pixels of the returned img | `800` |
7171
| c | center | center of the map lon,lat floats string | (center of the geojson) or `'-57.9524339,-34.921779'` |
72-
| z | zoom | zoomlevel of the leaflet map | if `vectorserverUrl` available, use `12` else `20` |
72+
| z | zoom | zoomlevel of the leaflet map | value of `maxZoom` |
7373
| Z | maxZoom | max zoomlevel of the leaflet map | `17` |
7474
| A | attribution | attribution legend | `'osm-static-maps / © OpenStreetMap contributors'` |
7575
| t | tileserverUrl | url of a tileserver | `'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png'` |

package-lock.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "osm-static-maps",
3-
"version": "4.0.0",
3+
"version": "4.0.1",
44
"description": "Create a static image of a map with the features you want",
55
"author": "Julian Perelli",
66
"contributors": [

src/cli.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ program
3030
)
3131
.option(
3232
"-z, --zoom <number>",
33-
"Zoomlevel of the map (default: vectorserverUrl ? 12 : 20)",
33+
"Zoomlevel of the map (default: maxZoom)",
3434
Number
3535
)
3636
.option("-Z, --maxZoom <number>", "Maximum zoomlevel of the map", Number, 17)

src/lib.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ interface OsmStaticMapsOptions {
3535

3636
/**
3737
* zoomlevel of the leaflet map
38-
* @defaultValue `vectorserverUrl` ? `12` : `20`
38+
* @defaultValue `maxZoom`
3939
*/
4040
zoom?: number;
4141

src/lib.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ export default function(options) {
162162
options.width = options.width || 800;
163163
options.center = options.center || '';
164164
options.zoom = options.zoom || '';
165-
options.maxZoom = options.maxZoom || (options.vectorserverUrl ? 20 : 17);
165+
options.maxZoom = options.maxZoom || 17;
166166
options.attribution = options.attribution || 'osm-static-maps | © OpenStreetMap contributors';
167167
options.tileserverUrl = options.tileserverUrl || 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png';
168168
options.vectorserverUrl = options.vectorserverUrl || '';

src/template.html

+13-6
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,13 @@
4343
<div id="map"></div>
4444
<script>
4545

46+
var initTime = performance.now();
47+
48+
function onLoadFn() {
49+
window.mapRendered = true;
50+
console.log('map rendered time: ' + (performance.now() - initTime) + 'ms');
51+
}
52+
4653
{{#if arrows}}
4754
var decorator = L.Symbol.arrowHead({
4855
pixelSize: 6,
@@ -135,10 +142,13 @@
135142
{{/if}}
136143

137144
{{#if vectorserverUrl}}
138-
var backgroundLayer = L.mapboxGL({
145+
var gl = L.mapboxGL({
139146
accessToken: '{{ vectorserverToken }}',
140147
style: '{{{ vectorserverUrl }}}'
141148
});
149+
gl.addTo(map);
150+
var backgroundLayer = gl.getMapboxMap();
151+
backgroundLayer.on('load', onLoadFn);
142152
{{else}}
143153
{{#if tileserverUrl}}
144154
var backgroundLayer = L.tileLayer(
@@ -148,13 +158,10 @@
148158
fadeAnimation: false
149159
}
150160
);
161+
backgroundLayer.addTo(map);
162+
backgroundLayer.on('load', onLoadFn);
151163
{{/if}}
152164
{{/if}}
153-
backgroundLayer.addTo(map);
154-
backgroundLayer.on('load', function() {
155-
window.mapRendered = true;
156-
});
157-
158165

159166
</script>
160167
</body>

0 commit comments

Comments
 (0)