Change default tiles for map view, allow customization
After the MapQuest debacle, there was a patch merged that replaced the MapQuest tiles with the OpenStreetMap ones (#501). IMO these are not a good default choice because while they might be fine for a small Recline project, heavy usage of them goes against their Terms of Use: http://wiki.openstreetmap.org/wiki/Tile_usage_policy More specifically: > Heavy use (e.g. distributing an app that uses tiles from openstreetmap.org) > is forbidden without prior permission from the System Administrators Popular CKAN instances that use Recline are likely to fall in this category. And also: > Highly Recommended: Do not hardcode any URL at tile.openstreetmap.org > into an app. This patch replaces the tiles with the Terrain tileset from Stamen (http://maps.stamen.com), which have more liberal terms. But more crucially, as this is something that different people will have different views on, it allows you to configure the tiles used by passing custom options to the view constructor, eg: view = new recline.View.Map({ model: dataset, mapTilesURL: '//{s}.tiles.mapbox.com/v4/mapbox.mapbox-streets-v7/{z}/{x}/{y}.png?access_token=pk.XXXX', mapTilesAttribution: '© MapBox etc..', mapTilesSubdomains: 'ab' }) So everybody (and apps integrating Recline like CKAN) can configure the tiles as they want.
This commit is contained in:
@@ -249,6 +249,30 @@ test('MapMenu', function () {
|
||||
assertPresent('.editor-field-type', controls.el);
|
||||
});
|
||||
|
||||
|
||||
test('Custom map options', function () {
|
||||
var dataset = GeoJSONFixture.getDataset();
|
||||
var view = new recline.View.Map({
|
||||
model: dataset,
|
||||
mapTilesURL: 'http://example.com/{z}/{y}/{x}.png',
|
||||
mapTilesAttribution: '© MyTiles',
|
||||
mapTilesSubdomains: 'ab'
|
||||
});
|
||||
$('.fixtures').append(view.el);
|
||||
view.render();
|
||||
|
||||
var tiles = view.$el.find('.leaflet-tile-pane');
|
||||
|
||||
assertPresent(tiles);
|
||||
|
||||
ok(tiles.find('.leaflet-tile')[0].src.startsWith('http://example.com'));
|
||||
|
||||
ok(view.$el.find('.leaflet-control-attribution').text().indexOf('MyTiles') !== -1);
|
||||
|
||||
view.remove();
|
||||
});
|
||||
|
||||
|
||||
var _getFeaturesCount = function(features){
|
||||
var cnt = 0;
|
||||
_.each(features._layers, function(layer) {
|
||||
|
||||
Reference in New Issue
Block a user