summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcus Lundblad <ml@update.uu.se>2019-05-21 22:54:57 +0200
committerMarcus Lundblad <ml@update.uu.se>2019-05-21 23:11:16 +0200
commit5e18b46347d778b9c0696f7b90ca12748f2c5dd2 (patch)
treee7e44bc2a1870398a98dca884da0ebd0e1351081
parent13a9d7665c187915b7e059f6d2141e4b86a9e4b0 (diff)
downloadgnome-maps-5e18b46347d778b9c0696f7b90ca12748f2c5dd2.tar.gz
geoJSONSource: Use tile size from downloaded service
Rather that using a hard-coded tile size, use a size matching the tile size as specified by the downloaded service definition. Fixes #180
-rw-r--r--src/geoJSONSource.js17
1 files changed, 8 insertions, 9 deletions
diff --git a/src/geoJSONSource.js b/src/geoJSONSource.js
index 5f9c26e2..3e432509 100644
--- a/src/geoJSONSource.js
+++ b/src/geoJSONSource.js
@@ -28,13 +28,11 @@ const Geojsonvt = imports.geojsonvt.geojsonvt;
const Location = imports.location;
const Place = imports.place;
const PlaceMarker = imports.placeMarker;
+const Service = imports.service;
const Utils = imports.utils;
const GeoJSONStyle = imports.geoJSONStyle;
const MapView = imports.mapView;
-
-const TILE_SIZE = 256;
-
const TileFeature = { POINT: 1,
LINESTRING: 2,
POLYGON: 3 };
@@ -48,6 +46,7 @@ class GeoJSONSource extends Champlain.TileSource {
this._mapView = params.mapView;
this._markerLayer = params.markerLayer;
this._bbox = new Champlain.BoundingBox();
+ this._tileSize = Service.getService().tiles.street.tile_size;
}
get bbox() {
@@ -55,7 +54,7 @@ class GeoJSONSource extends Champlain.TileSource {
}
vfunc_get_tile_size() {
- return TILE_SIZE;
+ return this._tileSize;
}
vfunc_get_max_zoom_level() {
@@ -211,17 +210,17 @@ class GeoJSONSource extends Champlain.TileSource {
parse(json) {
this._parseInternal(json);
- this._tileIndex = Geojsonvt.geojsonvt(json, { extent: TILE_SIZE,
+ this._tileIndex = Geojsonvt.geojsonvt(json, { extent: this._tileSize,
maxZoom: 20 });
this._clampBBox();
}
_renderTile(tile) {
let tileJSON = this._tileIndex.getTile(tile.zoom_level, tile.x, tile.y);
- let content = new Clutter.Canvas({ width: TILE_SIZE,
- height: TILE_SIZE });
- tile.content = new Clutter.Actor({ width: TILE_SIZE,
- height: TILE_SIZE,
+ let content = new Clutter.Canvas({ width: this._tileSize,
+ height: this._tileSize });
+ tile.content = new Clutter.Actor({ width: this._tileSize,
+ height: this._tileSize,
content: content });
content.connect('draw', (canvas, cr) => {