From 2ef5f99599dbe9eafe38d4c2869679f9a46ab31b Mon Sep 17 00:00:00 2001 From: Andreas Hocevar Date: Sun, 20 Aug 2017 09:26:37 -0400 Subject: [PATCH] Remove bundling magic for Mapbox styles script --- examples/mapbox-vector-tiles-advanced.js | 6 +----- examples/mapbox-vector-tiles.js | 7 +------ examples/resources/mapbox-streets-v6-style.js | 16 ++++++++-------- externs/example.js | 7 ++++++- 4 files changed, 16 insertions(+), 20 deletions(-) diff --git a/examples/mapbox-vector-tiles-advanced.js b/examples/mapbox-vector-tiles-advanced.js index 5bebe91531..ecfe823f08 100644 --- a/examples/mapbox-vector-tiles-advanced.js +++ b/examples/mapbox-vector-tiles-advanced.js @@ -1,4 +1,3 @@ -/* eslint-disable openlayers-internal/no-unused-requires */ goog.require('ol.Map'); goog.require('ol.View'); goog.require('ol.format.MVT'); @@ -46,7 +45,7 @@ var map = new ol.Map({ }), tileUrlFunction: tileUrlFunction }), - style: createMapboxStreetsV6Style() + style: createMapboxStreetsV6Style(ol.style.Style, ol.style.Fill, ol.style.Stroke, ol.style.Icon, ol.style.Text) }) ], target: 'map', @@ -56,6 +55,3 @@ var map = new ol.Map({ zoom: 2 }) }); - -// ol.style.Fill, ol.style.Icon, ol.style.Stroke, ol.style.Style and -// ol.style.Text are required for createMapboxStreetsV6Style() diff --git a/examples/mapbox-vector-tiles.js b/examples/mapbox-vector-tiles.js index 7512f12f27..c6a5329f90 100644 --- a/examples/mapbox-vector-tiles.js +++ b/examples/mapbox-vector-tiles.js @@ -1,5 +1,3 @@ -/* eslint-disable openlayers-internal/no-unused-requires */ - goog.require('ol.Map'); goog.require('ol.View'); goog.require('ol.format.MVT'); @@ -25,7 +23,7 @@ var map = new ol.Map({ url: 'https://{a-d}.tiles.mapbox.com/v4/mapbox.mapbox-streets-v6/' + '{z}/{x}/{y}.vector.pbf?access_token=' + key }), - style: createMapboxStreetsV6Style() + style: createMapboxStreetsV6Style(ol.style.Style, ol.style.Fill, ol.style.Stroke, ol.style.Icon, ol.style.Text) }) ], target: 'map', @@ -34,6 +32,3 @@ var map = new ol.Map({ zoom: 2 }) }); - -// ol.style.Fill, ol.style.Icon, ol.style.Stroke, ol.style.Style and -// ol.style.Text are required for createMapboxStreetsV6Style() diff --git a/examples/resources/mapbox-streets-v6-style.js b/examples/resources/mapbox-streets-v6-style.js index 3dc4d17dd3..c19a63be25 100644 --- a/examples/resources/mapbox-streets-v6-style.js +++ b/examples/resources/mapbox-streets-v6-style.js @@ -1,20 +1,20 @@ // Styles for the mapbox-streets-v6 vector tile data set. Loosely based on // http://a.tiles.mapbox.com/v4/mapbox.mapbox-streets-v6.json -function createMapboxStreetsV6Style() { - var fill = new ol.style.Fill({color: ''}); - var stroke = new ol.style.Stroke({color: '', width: 1}); - var polygon = new ol.style.Style({fill: fill}); - var strokedPolygon = new ol.style.Style({fill: fill, stroke: stroke}); - var line = new ol.style.Style({stroke: stroke}); - var text = new ol.style.Style({text: new ol.style.Text({ +function createMapboxStreetsV6Style(Style, Fill, Stroke, Icon, Text) { + var fill = new Fill({color: ''}); + var stroke = new Stroke({color: '', width: 1}); + var polygon = new Style({fill: fill}); + var strokedPolygon = new Style({fill: fill, stroke: stroke}); + var line = new Style({stroke: stroke}); + var text = new Style({text: new Text({ text: '', fill: fill, stroke: stroke })}); var iconCache = {}; function getIcon(iconName) { var icon = iconCache[iconName]; if (!icon) { - icon = new ol.style.Style({image: new ol.style.Icon({ + icon = new Style({image: new Icon({ src: 'https://cdn.rawgit.com/mapbox/maki/master/icons/' + iconName + '-15.svg', imgSize: [15, 15] })}); diff --git a/externs/example.js b/externs/example.js index 9ccb94b6ad..055c060dc3 100644 --- a/externs/example.js +++ b/externs/example.js @@ -13,7 +13,12 @@ common.getRendererFromQueryString = function(opt_default) {}; /** + * @param {function(new:ol.style.Style, olx.style.StyleOptions=)} Style Style constructor. + * @param {function(new:ol.style.Fill, olx.style.FillOptions=)} Fill Fill constructor. + * @param {function(new:ol.style.Stroke, olx.style.StrokeOptions=)} Stroke Stroke constructor. + * @param {function(new:ol.style.Icon, olx.style.IconOptions=)} Icon Icon constructor. + * @param {function(new:ol.style.Text, olx.style.TextOptions=)} Text Text constructor. * @return {function((ol.Feature|ol.render.Feature), number): * Array.} */ -var createMapboxStreetsV6Style = function() {}; +var createMapboxStreetsV6Style = function(Style, Fill, Stroke, Icon, Text) {};