New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

mapbox-gl

Package Overview
Dependencies
Maintainers
42
Versions
235
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mapbox-gl - npm Package Compare versions

Comparing version 0.9.0 to 0.10.0

bin/dump-vt.js

53

CHANGELOG.md

@@ -5,2 +5,55 @@ ## dev

## 0.10.0 (Aug 21 2015)
#### Breaking changes
* Switched to [longitude, latitude] coordinate order, matching GeoJSON. We anticipate that mapbox-gl-js will be widely used
with GeoJSON, and in the long term having a coordinate order that is consistent with GeoJSON will lead to less confusion
and impedence mismatch than will a [latitude, longitude] order.
The following APIs were renamed:
* `LatLng` was renamed to `LngLat`
* `LatLngBounds` was renamed to `LngLatBounds`
* `Popup#setLatLng` was renamed to `Popup#setLngLat`
* `Popup#getLatLng` was renamed to `Popup#getLngLat`
* The `latLng` property of Map events was renamed `lngLat`
The following APIs now expect array coordinates in [longitude, latitude] order:
* `LngLat.convert`
* `LngLatBounds.convert`
* `Popup#setLngLat`
* The `center` and `maxBounds` options of the `Map` constructor
* The arguments to `Map#setCenter`, `Map#fitBounds`, `Map#panTo`, and `Map#project`
* The `center` option of `Map#jumpTo`, `Map#easeTo`, and `Map#flyTo`
* The `around` option of `Map#zoomTo`, `Map#rotateTo`, and `Map#easeTo`
* The `coordinates` properties of video and image sources
* Updated to mapbox-gl-style-spec v8.0.0 ([Changelog](https://github.com/mapbox/mapbox-gl-style-spec/blob/v8.0.0/CHANGELOG.md)). Styles are
now expected to be version 8. You can use the [gl-style-migrate](https://github.com/mapbox/mapbox-gl-style-lint#migrations)
utility to update existing styles.
* The format for `mapbox://` style and glyphs URLs has changed. For style URLs, you should now use the format
`mapbox://styles/:username/:style`. The `:style` portion of the URL no longer contains a username. For font URLs, you
should now use the format `mapbox://fonts/:username/{fontstack}/{range}.pbf`.
* Mapbox default styles are now hosted via the Styles API rather than www.mapbox.com. You can make use of the Styles API
with a `mapbox://` style URL pointing to a v8 style, e.g. `mapbox://styles/mapbox/streets-v8`.
* The v8 satellite style (`mapbox://styles/mapbox/satellite-v8`) is now a plain satellite style, and not longer supports labels
or countour lines via classes. For a labeled satellite style, use `mapbox://styles/mapbox/satellite-hybrid`.
* Removed `mbgl.config.HTTP_URL` and `mbgl.config.FORCE_HTTPS`; https is always used when connecting to the Mapbox API.
* Renamed `mbgl.config.HTTPS_URL` to `mbgl.config.API_URL`.
#### Bugfixes
* Don't draw halo when halo-width is 0 (#1381)
* Reverted shader changes that degraded performance on IE
#### API Improvements
* You can now unset layout and paint properties via the `setLayoutProperty` and `setPaintProperty` APIs
by passing `undefined` as a property value.
* The `layer` option of `featuresAt` now supports an array of layers.
## 0.9.0 (Jul 29 2015)

@@ -7,0 +60,0 @@

4

js/data/buffer/buffer_set.js

@@ -13,2 +13,4 @@ 'use strict';

var CollisionBoxVertexBuffer = require('./collision_box_vertex_buffer');
var CircleVertexBuffer = require('./circle_vertex_buffer');
var CircleElementBuffer = require('./triangle_element_buffer');

@@ -22,2 +24,4 @@ module.exports = function(bufferset) {

iconElement: new IconElementBuffer(bufferset.iconElement),
circleVertex: new CircleVertexBuffer(bufferset.circleVertex),
circleElement: new CircleElementBuffer(bufferset.circleElement),
fillVertex: new FillVertexBuffer(bufferset.fillVertex),

@@ -24,0 +28,0 @@ fillElement: new FillElementBuffer(bufferset.fillElement),

@@ -8,2 +8,3 @@ 'use strict';

var SymbolBucket = require('./symbol_bucket');
var CircleBucket = require('./circle_bucket');
var LayoutProperties = require('../style/layout_properties');

@@ -22,6 +23,22 @@ var featureFilter = require('feature-filter');

if (layer.type === 'symbol') {
// To reduce the number of labels that jump around when zooming we need
// to use a text-size value that is the same for all zoom levels.
// This calculates text-size at a high zoom level so that all tiles can
// use the same value when calculating anchor positions.
if (values['text-size']) {
layout['text-max-size'] = values['text-size'].calculate(18, fakeZoomHistory);
layout['text-size'] = values['text-size'].calculate(z + 1, fakeZoomHistory);
}
if (values['icon-size']) {
layout['icon-max-size'] = values['icon-size'].calculate(18, fakeZoomHistory);
layout['icon-size'] = values['icon-size'].calculate(z + 1, fakeZoomHistory);
}
}
var BucketClass =
layer.type === 'line' ? LineBucket :
layer.type === 'fill' ? FillBucket :
layer.type === 'symbol' ? SymbolBucket : null;
layer.type === 'symbol' ? SymbolBucket :
layer.type === 'circle' ? CircleBucket : null;

@@ -28,0 +45,0 @@ var bucket = new BucketClass(buffers, new LayoutProperties[layer.type](layout), overscaling, z, collisionDebug);

2

js/data/feature_tree.js

@@ -60,3 +60,3 @@ 'use strict';

if (params.layer && layer !== params.layer.id)
if (params.layerIds && params.layerIds.indexOf(layer) < 0)
continue;

@@ -63,0 +63,0 @@

@@ -82,3 +82,3 @@ 'use strict';

var textOffset = [layout['text-offset'][0] * oneEm, layout['text-offset'][1] * oneEm];
var fontstack = layout['text-font'];
var fontstack = layout['text-font'].join(',');

@@ -141,6 +141,7 @@ var geometries = [];

var fontScale = layout['text-max-size'] / glyphSize,
var fontScale = layout['text-size'] / glyphSize,
textBoxScale = this.tilePixelRatio * fontScale,
iconBoxScale = this.tilePixelRatio * layout['icon-max-size'],
symbolMinDistance = this.tilePixelRatio * layout['symbol-min-distance'],
textMaxBoxScale = this.tilePixelRatio * layout['text-max-size'] / glyphSize,
iconBoxScale = this.tilePixelRatio * layout['icon-size'],
symbolMinDistance = this.tilePixelRatio * layout['symbol-spacing'],
avoidEdges = layout['symbol-avoid-edges'],

@@ -166,3 +167,3 @@ textPadding = layout['text-padding'] * this.tilePixelRatio,

var anchors = isLine ?
getAnchors(line, symbolMinDistance, textMaxAngle, shapedText, shapedIcon, glyphSize, textBoxScale, this.overscaling) :
getAnchors(line, symbolMinDistance, textMaxAngle, shapedText, shapedIcon, glyphSize, textMaxBoxScale, this.overscaling) :
[ new Anchor(line[0].x, line[0].y, 0) ];

@@ -237,2 +238,5 @@

elementGroups.text['text-size'] = layout['text-size'];
elementGroups.icon['icon-size'] = layout['icon-size'];
var textAlongLine = layout['text-rotation-alignment'] === 'map' && layout['symbol-placement'] === 'line';

@@ -239,0 +243,0 @@ var iconAlongLine = layout['icon-rotation-alignment'] === 'map' && layout['symbol-placement'] === 'line';

'use strict';
var LatLng = require('./lat_lng'),
var LngLat = require('./lng_lat'),
Point = require('point-geometry'),

@@ -32,3 +32,3 @@ Coordinate = require('./coordinate'),

this.zoom = 0;
this.center = new LatLng(0, 0);
this.center = new LngLat(0, 0);
this.angle = 0;

@@ -98,12 +98,12 @@ this._altitude = 1.5;

project: function(latlng, worldSize) {
project: function(lnglat, worldSize) {
return new Point(
this.lngX(latlng.lng, worldSize),
this.latY(latlng.lat, worldSize));
this.lngX(lnglat.lng, worldSize),
this.latY(lnglat.lat, worldSize));
},
unproject: function(point, worldSize) {
return new LatLng(
this.yLat(point.y, worldSize),
this.xLng(point.x, worldSize));
return new LngLat(
this.xLng(point.x, worldSize),
this.yLat(point.y, worldSize));
},

@@ -117,3 +117,3 @@

/**
* lat/lon <-> absolute pixel coords conversion
* latitude to absolute x coord
* @param {number} lon

@@ -124,8 +124,7 @@ * @param {number} [worldSize=this.worldSize]

*/
lngX: function(lon, worldSize) {
return (180 + lon) * (worldSize || this.worldSize) / 360;
lngX: function(lng, worldSize) {
return (180 + lng) * (worldSize || this.worldSize) / 360;
},
/**
* latitude to absolute y coord
*
* @param {number} lat

@@ -155,4 +154,4 @@ * @param {number} [worldSize=this.worldSize]

setLocationAtPoint: function(latlng, point) {
var c = this.locationCoordinate(latlng);
setLocationAtPoint: function(lnglat, point) {
var c = this.locationCoordinate(lnglat);
var coordAtPoint = this.pointCoordinate(point);

@@ -183,14 +182,14 @@ var coordCenter = this.pointCoordinate(this.centerPoint);

* Given a location, return the screen point that corresponds to it
* @param {LatLng} latlng location
* @param {LngLat} lnglat location
* @returns {Point} screen point
* @private
*/
locationPoint: function(latlng) {
return this.coordinatePoint(this.locationCoordinate(latlng));
locationPoint: function(lnglat) {
return this.coordinatePoint(this.locationCoordinate(lnglat));
},
/**
* Given a point on screen, return its latlng
* Given a point on screen, return its lnglat
* @param {Point} p screen point
* @returns {LatLng} latlng location
* @returns {LngLat} lnglat location
* @private

@@ -203,14 +202,14 @@ */

/**
* Given a geographical latlng, return an unrounded
* Given a geographical lnglat, return an unrounded
* coordinate that represents it at this transform's zoom level and
* worldsize.
* @param {LatLng} latlng
* @param {LngLat} lnglat
* @returns {Coordinate}
* @private
*/
locationCoordinate: function(latlng) {
locationCoordinate: function(lnglat) {
var k = this.zoomScale(this.tileZoom) / this.worldSize;
return new Coordinate(
this.lngX(latlng.lng) * k,
this.latY(latlng.lat) * k,
this.lngX(lnglat.lng) * k,
this.latY(lnglat.lat) * k,
this.tileZoom);

@@ -222,3 +221,3 @@ },

* @param {Coordinate} coord
* @returns {LatLng} latlng
* @returns {LngLat} lnglat
* @private

@@ -228,5 +227,5 @@ */

var worldSize = this.zoomScale(coord.zoom);
return new LatLng(
this.yLat(coord.row, worldSize),
this.xLng(coord.column, worldSize));
return new LngLat(
this.xLng(coord.column, worldSize),
this.yLat(coord.row, worldSize));
},

@@ -233,0 +232,0 @@

@@ -22,7 +22,8 @@ 'use strict';

mapboxgl.VideoSource = require('./source/video_source');
mapboxgl.ImageSource = require('./source/image_source');
mapboxgl.Style = require('./style/style');
mapboxgl.LatLng = require('./geo/lat_lng');
mapboxgl.LatLngBounds = require('./geo/lat_lng_bounds');
mapboxgl.LngLat = require('./geo/lng_lat');
mapboxgl.LngLatBounds = require('./geo/lng_lat_bounds');
mapboxgl.Point = require('point-geometry');

@@ -29,0 +30,0 @@

@@ -10,3 +10,3 @@ 'use strict';

var color = layer.paint['background-color'];
var image = layer.paint['background-image'];
var image = layer.paint['background-pattern'];
var opacity = layer.paint['background-opacity'];

@@ -76,4 +76,3 @@ var shader;

gl.switchShader(shader, posMatrix);
gl.disableVertexAttribArray(shader.a_color);
gl.vertexAttrib4fv(shader.a_color, color);
gl.uniform4fv(shader.u_color, color);
}

@@ -80,0 +79,0 @@

@@ -55,4 +55,2 @@ 'use strict';

gl.disableVertexAttribArray(painter.fillShader.a_color);
for (var i = 0; i < elementGroups.groups.length; i++) {

@@ -80,3 +78,3 @@ group = elementGroups.groups[i];

// below, we have to draw the outline first (!)
if (layer.paint['fill-antialias'] === true && !(layer.paint['fill-image'] && !strokeColor)) {
if (layer.paint['fill-antialias'] === true && !(layer.paint['fill-pattern'] && !strokeColor)) {
gl.switchShader(painter.outlineShader, translatedPosMatrix);

@@ -100,2 +98,3 @@ gl.lineWidth(2 * browser.devicePixelRatio);

gl.uniform2f(painter.outlineShader.u_world, gl.drawingBufferWidth, gl.drawingBufferHeight);
gl.uniform4fv(painter.outlineShader.u_color, strokeColor ? strokeColor : color);

@@ -107,5 +106,2 @@ // Draw all buffers

gl.disableVertexAttribArray(painter.outlineShader.a_color);
gl.vertexAttrib4fv(painter.outlineShader.a_color, strokeColor ? strokeColor : color);
for (var k = 0; k < elementGroups.groups.length; k++) {

@@ -122,3 +118,3 @@ group = elementGroups.groups[k];

var image = layer.paint['fill-image'];
var image = layer.paint['fill-pattern'];
var opacity = layer.paint['fill-opacity'] || 1;

@@ -166,4 +162,3 @@ var shader;

gl.switchShader(shader, posMatrix);
gl.disableVertexAttribArray(shader.a_color);
gl.vertexAttrib4fv(shader.a_color, color);
gl.uniform4fv(shader.u_color, color);
}

@@ -170,0 +165,0 @@

@@ -71,3 +71,3 @@ 'use strict';

var dasharray = layer.paint['line-dasharray'];
var image = layer.paint['line-image'];
var image = layer.paint['line-pattern'];

@@ -79,3 +79,5 @@ if (dasharray) {

gl.uniform2fv(shader.u_linewidth, [ outset, inset ]);
gl.uniform1f(shader.u_ratio, ratio);
gl.uniform1f(shader.u_blur, blur);

@@ -112,3 +114,5 @@ var posA = painter.lineAtlas.getDash(dasharray.from, layer.layout['line-cap'] === 'round');

gl.uniform2fv(shader.u_linewidth, [ outset, inset ]);
gl.uniform1f(shader.u_ratio, ratio);
gl.uniform1f(shader.u_blur, blur);

@@ -122,6 +126,4 @@ gl.uniform2fv(shader.u_pattern_size_a, [imagePosA.size[0] * factor * image.fromScale, imagePosB.size[1] ]);

gl.uniform1f(shader.u_fade, image.t);
gl.uniform1f(shader.u_opacity, layer.paint['line-opacity']);
gl.disableVertexAttribArray(shader.a_opacity);
gl.vertexAttrib1f(shader.a_opacity, layer.paint['line-opacity']);
} else {

@@ -131,3 +133,5 @@ shader = painter.lineShader;

gl.uniform2fv(shader.u_linewidth, [ outset, inset ]);
gl.uniform1f(shader.u_ratio, ratio);
gl.uniform1f(shader.u_blur, blur);
gl.uniform1f(shader.u_extra, extra);

@@ -137,14 +141,2 @@ gl.uniformMatrix2fv(shader.u_antialiasingmatrix, false, antialiasingMatrix);

// linepattern does not have a color attribute
if (shader.a_color !== undefined) {
gl.disableVertexAttribArray(shader.a_color);
gl.vertexAttrib4fv(shader.a_color, color);
}
gl.disableVertexAttribArray(shader.a_linewidth);
gl.vertexAttrib2f(shader.a_linewidth, outset, inset);
gl.disableVertexAttribArray(shader.a_blur);
gl.vertexAttrib1f(shader.a_blur, blur);
var vertex = tile.buffers.lineVertex;

@@ -155,2 +147,4 @@ vertex.bind(gl);

gl.disableVertexAttribArray(shader.a_color);
for (var i = 0; i < elementGroups.groups.length; i++) {

@@ -161,2 +155,3 @@ var group = elementGroups.groups[i];

gl.vertexAttribPointer(shader.a_data, 4, gl.BYTE, false, 8, vtxOffset + 4);
gl.vertexAttrib4f(shader.a_color, color[0], color[1], color[2], color[3]);

@@ -167,2 +162,5 @@ var count = group.elementLength * 3;

}
gl.enableVertexAttribArray(shader.a_color);
};

@@ -70,3 +70,2 @@ 'use strict';

// If layer.paint.size > layer.layout[prefix + '-max-size'] then labels may collide
var fontSize = layer.paint[prefix + '-size'];

@@ -115,5 +114,6 @@ var fontScale = fontSize / defaultSizes[prefix];

// adjust min/max zooms for variable font sies
var zoomAdjust = Math.log(fontSize / layer.layout[prefix + '-max-size']) / Math.LN2 || 0;
// adjust min/max zooms for variable font sizes
var zoomAdjust = Math.log(fontSize / elementGroups[prefix + '-size']) / Math.LN2 || 0;
gl.uniform1f(shader.u_zoom, (painter.transform.zoom - zoomAdjust) * 10); // current zoom level

@@ -137,11 +137,6 @@

gl.disableVertexAttribArray(shader.a_gamma);
gl.vertexAttrib1f(shader.a_gamma, gamma * gammaScale);
gl.uniform1f(shader.u_gamma, gamma * gammaScale);
gl.uniform4fv(shader.u_color, layer.paint[prefix + '-color']);
gl.uniform1f(shader.u_buffer, (256 - 64) / 256);
gl.disableVertexAttribArray(shader.a_color);
gl.vertexAttrib4fv(shader.a_color, layer.paint[prefix + '-color']);
gl.disableVertexAttribArray(shader.a_buffer);
gl.vertexAttrib1f(shader.a_buffer, (256 - 64) / 256);
for (var i = 0; i < elementGroups.groups.length; i++) {

@@ -157,9 +152,8 @@ group = elementGroups.groups[i];

if (layer.paint[prefix + '-halo-color']) {
if (layer.paint[prefix + '-halo-width']) {
// Draw halo underneath the text.
gl.uniform1f(shader.u_gamma, (layer.paint[prefix + '-halo-blur'] * blurOffset / fontScale / sdfPx + gamma) * gammaScale);
gl.uniform4fv(shader.u_color, layer.paint[prefix + '-halo-color']);
gl.uniform1f(shader.u_buffer, (haloOffset - layer.paint[prefix + '-halo-width'] / fontScale) / sdfPx);
// vertex attrib arrays disabled above
gl.vertexAttrib4fv(shader.a_color, layer.paint[prefix + '-halo-color']);
gl.vertexAttrib1f(shader.a_buffer, (haloOffset - layer.paint[prefix + '-halo-width'] / fontScale) / sdfPx);
gl.vertexAttrib1f(shader.a_gamma, (layer.paint[prefix + '-halo-blur'] * blurOffset / fontScale / sdfPx + gamma) * gammaScale);
for (var j = 0; j < elementGroups.groups.length; j++) {

@@ -176,5 +170,3 @@ group = elementGroups.groups[j];

} else {
gl.disableVertexAttribArray(shader.a_opacity);
gl.vertexAttrib1f(shader.a_opacity, layer.paint['icon-opacity']);
gl.uniform1f(shader.u_opacity, layer.paint['icon-opacity']);
for (var k = 0; k < elementGroups.groups.length; k++) {

@@ -181,0 +173,0 @@ group = elementGroups.groups[k];

@@ -45,12 +45,2 @@ 'use strict';

this.attachShader(shader.program, shader.fragment);
// Disabling attrib location 0 causes weird behaviour. To avoid the problem, we assign
// 'a_pos' to attrib location 0 making the assumptions that
//
// - `a_pos` is never disabled
// - every shader has an `a_pos` attribute
//
// see: https://developer.mozilla.org/en-US/docs/Web/WebGL/WebGL_best_practices
this.bindAttribLocation(shader.program, 0, 'a_pos');
this.linkProgram(shader.program);

@@ -82,13 +72,18 @@

// Disable all attribute arrays used by the previous shader and enable all the attribute
// arrays used by the next shader. Ideally we would do a better job diffing these to
// minimize operations (as we did in previously) but it is hard to keep track of state
// in spaghetti shader boilerplate code and hard to debug when things go wrong.
var previous = this.currentShader ? this.currentShader.attributes : [];
for (var i = 0; i < previous.length; i++) {
this.disableVertexAttribArray(previous[i]);
// Disable all attributes from the existing shader that aren't used in
// the new shader. Note: attribute indices are *not* program specific!
var enabled = this.currentShader ? this.currentShader.attributes : [];
var required = shader.attributes;
for (var i = 0; i < enabled.length; i++) {
if (required.indexOf(enabled[i]) < 0) {
this.disableVertexAttribArray(enabled[i]);
}
}
var next = shader.attributes;
for (var j = 0; j < next.length; j++) {
this.enableVertexAttribArray(next[j]);
// Enable all attributes for the new shader.
for (var j = 0; j < required.length; j++) {
if (enabled.indexOf(required[j]) < 0) {
this.enableVertexAttribArray(required[j]);
}
}

@@ -112,2 +107,3 @@

context.vertexAttrib2fv = function(attribute, values) {

@@ -114,0 +110,0 @@ context.vertexAttrib2f(attribute, values[0], values[1]);

@@ -57,6 +57,2 @@ 'use strict';

this.gaussianShader = gl.initializeShader('gaussian',
['a_pos'],
['u_matrix', 'u_image', 'u_offset']);
this.rasterShader = gl.initializeShader('raster',

@@ -66,13 +62,17 @@ ['a_pos', 'a_texture_pos'],

this.circleShader = gl.initializeShader('circle',
['a_pos'],
['u_matrix', 'u_exmatrix', 'u_blur', 'u_size', 'u_color']);
this.lineShader = gl.initializeShader('line',
['a_pos', 'a_data', 'a_color', 'a_linewidth', 'a_blur'],
['u_matrix', 'u_ratio', 'u_extra', 'u_antialiasingmatrix']);
['a_pos', 'a_data', 'a_color'],
['u_matrix', 'u_linewidth', 'u_ratio', 'u_blur', 'u_extra', 'u_antialiasingmatrix']);
this.linepatternShader = gl.initializeShader('linepattern',
['a_pos', 'a_data', 'a_linewidth', 'a_blur', 'a_opacity'],
['u_matrix', 'u_exmatrix', 'u_ratio', 'u_pattern_size_a', 'u_pattern_size_b', 'u_pattern_tl_a', 'u_pattern_br_a', 'u_pattern_tl_b', 'u_pattern_br_b', 'u_fade']);
['a_pos', 'a_data', 'a_color'],
['u_matrix', 'u_exmatrix', 'u_linewidth', 'u_ratio', 'u_pattern_size_a', 'u_pattern_size_b', 'u_pattern_tl_a', 'u_pattern_br_a', 'u_pattern_tl_b', 'u_pattern_br_b', 'u_blur', 'u_fade', 'u_opacity']);
this.linesdfpatternShader = gl.initializeShader('linesdfpattern',
['a_pos', 'a_data', 'a_color', 'a_linewidth', 'a_blur'],
['u_matrix', 'u_exmatrix', 'u_ratio', 'u_patternscale_a', 'u_tex_y_a', 'u_patternscale_b', 'u_tex_y_b', 'u_image', 'u_sdfgamma', 'u_mix']);
['a_pos', 'a_data', 'a_color'],
['u_matrix', 'u_exmatrix', 'u_linewidth', 'u_ratio', 'u_blur', 'u_patternscale_a', 'u_tex_y_a', 'u_patternscale_b', 'u_tex_y_b', 'u_image', 'u_sdfgamma', 'u_mix']);

@@ -84,12 +84,12 @@ this.dotShader = gl.initializeShader('dot',

this.sdfShader = gl.initializeShader('sdf',
['a_pos', 'a_offset', 'a_data1', 'a_data2', 'a_color', 'a_buffer', 'a_gamma'],
['u_matrix', 'u_exmatrix', 'u_texture', 'u_texsize', 'u_zoom', 'u_fadedist', 'u_minfadezoom', 'u_maxfadezoom', 'u_fadezoom', 'u_skewed', 'u_extra']);
['a_pos', 'a_offset', 'a_data1', 'a_data2'],
['u_matrix', 'u_exmatrix', 'u_texture', 'u_texsize', 'u_color', 'u_gamma', 'u_buffer', 'u_zoom', 'u_fadedist', 'u_minfadezoom', 'u_maxfadezoom', 'u_fadezoom', 'u_skewed', 'u_extra']);
this.iconShader = gl.initializeShader('icon',
['a_pos', 'a_offset', 'a_data1', 'a_data2', 'a_opacity'],
['u_matrix', 'u_exmatrix', 'u_texture', 'u_texsize', 'u_zoom', 'u_fadedist', 'u_minfadezoom', 'u_maxfadezoom', 'u_fadezoom', 'u_skewed', 'u_extra']);
['a_pos', 'a_offset', 'a_data1', 'a_data2'],
['u_matrix', 'u_exmatrix', 'u_texture', 'u_texsize', 'u_zoom', 'u_fadedist', 'u_minfadezoom', 'u_maxfadezoom', 'u_fadezoom', 'u_opacity', 'u_skewed', 'u_extra']);
this.outlineShader = gl.initializeShader('outline',
['a_pos', 'a_color'],
['u_matrix', 'u_world']
['a_pos'],
['u_matrix', 'u_color', 'u_world']
);

@@ -103,4 +103,4 @@

this.fillShader = gl.initializeShader('fill',
['a_pos', 'a_color'],
['u_matrix']
['a_pos'],
['u_matrix', 'u_color']
);

@@ -214,3 +214,2 @@

// Draw the clipping mask
gl.disableVertexAttribArray(this.fillShader.a_color);
gl.bindBuffer(gl.ARRAY_BUFFER, this.tileExtentBuffer);

@@ -224,3 +223,2 @@ gl.vertexAttribPointer(this.fillShader.a_pos, this.tileExtentBuffer.itemSize, gl.SHORT, false, 8, 0);

gl.colorMask(true, true, true, true);
gl.enableVertexAttribArray(this.fillShader.a_color);
};

@@ -237,2 +235,3 @@

symbol: require('./draw_symbol'),
circle: require('./draw_circle'),
line: require('./draw_line'),

@@ -315,4 +314,4 @@ fill: require('./draw_fill'),

gl.vertexAttribPointer(this.fillShader.a_pos, this.backgroundBuffer.itemSize, gl.SHORT, false, 0, 0);
gl.disableVertexAttribArray(this.fillShader.a_color);
gl.vertexAttrib4fv(this.fillShader.a_color, [0, 0, 0, 0.5]);
gl.uniform4fv(this.fillShader.u_color, [0, 0, 0, 0.5]);
gl.drawArrays(gl.TRIANGLE_STRIP, 0, this.tileExtentBuffer.itemCount);

@@ -319,0 +318,0 @@

@@ -9,3 +9,3 @@ 'use strict';

"fill": glify('../../shaders/fill.*.glsl'),
"gaussian": glify('../../shaders/gaussian.*.glsl'),
"circle": glify('../../shaders/circle.*.glsl'),
"line": glify('../../shaders/line.*.glsl'),

@@ -12,0 +12,0 @@ "linepattern": glify('../../shaders/linepattern.*.glsl'),

@@ -113,3 +113,4 @@ 'use strict';

geojson: require('./geojson_source'),
video: require('./video_source')
video: require('./video_source'),
image: require('./image_source')
};

@@ -116,0 +117,0 @@

@@ -5,6 +5,5 @@ 'use strict';

var Tile = require('./tile');
var LatLng = require('../geo/lat_lng');
var LngLat = require('../geo/lng_lat');
var Point = require('point-geometry');
var Evented = require('../util/evented');
var Coordinate = require('../geo/coordinate');
var ajax = require('../util/ajax');

@@ -19,3 +18,3 @@

* @param {string|Array} options.url A string or array of URL(s) to video files
* @param {Array} options.coordinates lat,lng coordinates in order clockwise starting at the top left: tl, tr, br, bl
* @param {Array} options.coordinates lng, lat coordinates in order clockwise starting at the top left: tl, tr, br, bl
* @example

@@ -28,6 +27,6 @@ * var sourceObj = new mapboxgl.VideoSource({

* coordinates: [
* [39.18579907229748, -76.54335737228394],
* [39.1838364847587, -76.52803659439087],
* [39.17683392507606, -76.5295386314392],
* [39.17876344106642, -76.54520273208618]
* [-76.54335737228394, 39.18579907229748],
* [-76.52803659439087, 39.1838364847587],
* [-76.5295386314392, 39.17683392507606],
* [-76.54520273208618, 39.17876344106642]
* ]

@@ -41,3 +40,3 @@ * });

ajax.getVideo(options.url, function(err, video) {
ajax.getVideo(options.urls, function(err, video) {
// @TODO handle errors via event.

@@ -99,25 +98,8 @@ if (err) return;

var map = this.map;
var coords = this.coordinates.map(function(latlng) {
var loc = LatLng.convert(latlng);
var coords = this.coordinates.map(function(lnglat) {
var loc = LngLat.convert(lnglat);
return map.transform.locationCoordinate(loc).zoomTo(0);
});
var minX = Infinity;
var minY = Infinity;
var maxX = -Infinity;
var maxY = -Infinity;
for (var i = 0; i < coords.length; i++) {
minX = Math.min(minX, coords[i].column);
minY = Math.min(minY, coords[i].row);
maxX = Math.max(maxX, coords[i].column);
maxY = Math.max(maxY, coords[i].row);
}
var dx = maxX - minX;
var dy = maxY - minY;
var dMax = Math.max(dx, dy);
var center = new Coordinate((minX + maxX) / 2, (minY + maxY) / 2, 0)
.zoomTo(Math.floor(-Math.log(dMax) / Math.LN2));
var center = util.getCoordinatesCenter(coords);
var tileExtent = 4096;

@@ -124,0 +106,0 @@ var tileCoords = coords.map(function(coord) {

@@ -138,3 +138,3 @@ 'use strict';

for (i = 0; i < bucketsInOrder.length; i++) {
for (i = bucketsInOrder.length - 1; i >= 0; i--) {
bucket = bucketsInOrder[i];

@@ -248,3 +248,3 @@

var bucketsInOrder = this.bucketsInOrder;
for (var i = 0; i < bucketsInOrder.length; i++) {
for (var i = bucketsInOrder.length - 1; i >= 0; i--) {
var bucket = bucketsInOrder[i];

@@ -251,0 +251,0 @@

@@ -6,2 +6,3 @@ 'use strict';

var browser = require('../util/browser');
var normalizeURL = require('../util/mapbox').normalizeSpriteURL;

@@ -14,5 +15,5 @@ module.exports = ImageSprite;

base = this.base + (this.retina ? '@2x' : '');
var format = this.retina ? '@2x' : '';
ajax.getJSON(base + '.json', function(err, data) {
ajax.getJSON(normalizeURL(base, format, '.json'), function(err, data) {
if (err) {

@@ -27,3 +28,3 @@ this.fire('error', {error: err});

ajax.getImage(base + '.png', function(err, img) {
ajax.getImage(normalizeURL(base, format, '.png'), function(err, img) {
if (err) {

@@ -30,0 +31,0 @@ this.fire('error', {error: err});

@@ -17,3 +17,5 @@ 'use strict';

if (value === undefined) continue;
if (prop.type === 'color') value = parseCSSColor(value);
if (prop.type === 'color') {
value = parseCSSColor(value);
}

@@ -20,0 +22,0 @@ Calculated.prototype[p] = value;

@@ -50,3 +50,3 @@ 'use strict';

if (!(layer instanceof StyleLayer)) {
layer = new StyleLayer(layer, this._style.stylesheet.constants || {});
layer = new StyleLayer(layer);
}

@@ -53,0 +53,0 @@ this._style._layers[layer.id] = layer;

@@ -5,3 +5,2 @@ 'use strict';

var reference = require('./reference');
var StyleConstant = require('./style_constant');
var StyleDeclaration = require('./style_declaration');

@@ -20,10 +19,8 @@

function makeConstructor(reference) {
function StyleDeclarationSet(properties, constants) {
function StyleDeclarationSet(properties) {
this._values = {};
this._transitions = {};
this._constants = constants;
for (var k in properties) {
this[k] = StyleConstant.resolve(properties[k], this._constants);
this[k] = properties[k];
}

@@ -37,3 +34,3 @@ }

set: function(v) {
this._values[k] = new StyleDeclaration(property, StyleConstant.resolve(v, this._constants));
this._values[k] = new StyleDeclaration(property, v);
},

@@ -86,4 +83,4 @@ get: function() {

module.exports = function(renderType, layerType, properties, constants) {
return new lookup[renderType][layerType](properties, constants);
module.exports = function(renderType, layerType, properties) {
return new lookup[renderType][layerType](properties);
};
'use strict';
var parseCSSColor = require('csscolorparser').parseCSSColor;
var mapboxGLFunction = require('mapbox-gl-function');
var MapboxGLFunction = require('mapbox-gl-function');
var util = require('../util/util');

@@ -13,17 +13,19 @@

if (value == null) {
value = reference.default;
}
// immutable representation of value. used for comparison
this.json = JSON.stringify(value);
if (this.type !== 'color') {
if (this.type === 'color') {
this.value = parseColor(value);
} else {
this.value = value;
} else if (value.stops) {
this.value = prepareColorFunction(value);
} else {
this.value = parseColor(value);
}
if (reference.function === 'interpolated') {
this.calculate = mapboxGLFunction.interpolated(this.value);
this.calculate = MapboxGLFunction.interpolated(this.value);
} else {
this.calculate = mapboxGLFunction['piecewise-constant'](this.value);
this.calculate = MapboxGLFunction['piecewise-constant'](this.value);
if (reference.transition) {

@@ -67,17 +69,33 @@ this.calculate = transitioned(this.calculate);

function parseColor(value) {
if (colorCache[value]) return colorCache[value];
var color = prepareColor(parseCSSColor(value));
colorCache[value] = color;
return color;
}
function parseColor(input) {
function prepareColor(c) {
return [c[0] / 255, c[1] / 255, c[2] / 255, c[3] / 1];
if (colorCache[input]) {
return colorCache[input];
// RGBA array
} else if (Array.isArray(input)) {
return input;
// GL function
} else if (input.stops) {
return util.extend({}, input, {
stops: input.stops.map(function(step) {
return [step[0], parseColor(step[1])];
})
});
// Color string
} else if (typeof input === 'string') {
var output = colorDowngrade(parseCSSColor(input));
colorCache[input] = output;
return output;
} else {
throw new Error('Invalid color ' + input);
}
}
function prepareColorFunction(f) {
return util.extend({}, f, {stops: f.stops.map(function(stop) {
return [stop[0], parseColor(stop[1])];
})});
function colorDowngrade(color) {
return [color[0] / 255, color[1] / 255, color[2] / 255, color[3] / 1];
}
'use strict';
var util = require('../util/util');
var StyleConstant = require('./style_constant');
var StyleTransition = require('./style_transition');

@@ -12,5 +11,4 @@ var StyleDeclarationSet = require('./style_declaration_set');

function StyleLayer(layer, constants) {
function StyleLayer(layer) {
this._layer = layer;
this._constants = constants;

@@ -30,4 +28,3 @@ this.id = layer.id;

if (!this.ref) {
this.layout = new LayoutProperties[this.type](
StyleConstant.resolveAll(this._layer.layout, this._constants));
this.layout = new LayoutProperties[this.type](this._layer.layout);

@@ -43,2 +40,4 @@ if (this.layout['symbol-placement'] === 'line') {

}
this._resolvedLayout = new StyleDeclarationSet('layout', this.type, this.layout, this._constants || {});
}

@@ -48,3 +47,7 @@ },

setLayoutProperty: function(name, value) {
this.layout[name] = StyleConstant.resolve(value, this._constants);
if (value == null) {
delete this.layout[name];
} else {
this.layout[name] = value;
}
},

@@ -68,3 +71,3 @@

this._resolved[match[1] || ''] =
new StyleDeclarationSet('paint', this.type, this._layer[p], this._constants);
new StyleDeclarationSet('paint', this.type, this._layer[p]);
}

@@ -77,3 +80,3 @@ },

declarations = this._resolved[klass || ''] =
new StyleDeclarationSet('paint', this.type, {}, this._constants);
new StyleDeclarationSet('paint', this.type, {});
}

@@ -119,4 +122,12 @@ declarations[name] = value;

}
},
// the -size properties are used both as layout and paint.
// In the spec they are layout properties. This adds them
// as internal paint properties.
if (this.type === 'symbol') {
this._cascaded['text-size'] = new StyleTransition(this._resolvedLayout.values()['text-size'], undefined, globalTrans);
this._cascaded['icon-size'] = new StyleTransition(this._resolvedLayout.values()['icon-size'], undefined, globalTrans);
}
},
recalculate: function(z, zoomHistory) {

@@ -169,3 +180,3 @@ var type = this.type,

'minzoom', 'maxzoom', 'filter',
'layout']));
'layout', '_resolvedLayout']));
},

@@ -172,0 +183,0 @@

@@ -104,3 +104,3 @@ 'use strict';

for (var i = 0; i < this.stylesheet.layers.length; i++) {
layer = new StyleLayer(this.stylesheet.layers[i], this.stylesheet.constants || {});
layer = new StyleLayer(this.stylesheet.layers[i]);
this._layers[layer.id] = layer;

@@ -381,3 +381,3 @@ this._order.push(layer.id);

if (params.layer) {
params.layer = { id: params.layer };
params.layerIds = Array.isArray(params.layer) ? params.layer : [params.layer];
}

@@ -384,0 +384,0 @@

@@ -6,4 +6,4 @@ 'use strict';

var browser = require('../util/browser');
var LatLng = require('../geo/lat_lng');
var LatLngBounds = require('../geo/lat_lng_bounds');
var LngLat = require('../geo/lng_lat');
var LngLatBounds = require('../geo/lng_lat_bounds');
var Point = require('point-geometry');

@@ -17,3 +17,3 @@

* @typedef {Object} CameraOptions
* @property {Array} center Latitude and longitude (passed as `[lat, lng]`)
* @property {Array} center Longitude and latitude (passed as `[lng, lat]`)
* @property {number} zoom Map zoom level

@@ -41,3 +41,3 @@ * @property {number} bearing Map rotation bearing in degrees counter-clockwise from north

* Get the current view geographical point.
* @returns {LatLng}
* @returns {LngLat}
*/

@@ -49,3 +49,3 @@ getCenter: function() { return this.transform.center; },

*
* @param {Array} center Latitude and longitude (passed as `[lat, lng]`)
* @param {Array} center Longitude and latitude (passed as `[lng, lat]`)
* @fires movestart

@@ -79,3 +79,3 @@ * @fires moveend

*
* @param {Object} latlng a `LatLng` object
* @param {LngLat|Array<number>} lnglat
* @param {AnimationOptions} [options]

@@ -86,6 +86,6 @@ * @fires movestart

*/
panTo: function(latlng, options) {
panTo: function(lnglat, options) {
this.stop();
latlng = LatLng.convert(latlng);
lnglat = LngLat.convert(lnglat);

@@ -101,3 +101,3 @@ options = util.extend({

from = tr.point,
to = tr.project(latlng).sub(offset);
to = tr.project(lnglat).sub(offset);

@@ -164,3 +164,3 @@ if (!options.noMoveStart) {

if (options.around) {
around = LatLng.convert(options.around);
around = LngLat.convert(options.around);
} else if (options.offset) {

@@ -270,3 +270,3 @@ around = tr.pointLocation(tr.centerPoint.add(Point.convert(options.offset)));

if (options.around) {
around = LatLng.convert(options.around);
around = LngLat.convert(options.around);
} else if (options.offset) {

@@ -343,3 +343,3 @@ around = tr.pointLocation(tr.centerPoint.add(Point.convert(options.offset)));

*
* @param {Array} bounds [[minLat, minLng], [maxLat, maxLng]]
* @param {LngLatBounds|Array<Array<number>>} bounds [[minLng, minLat], [maxLng, maxLat]]
* @param {Object} options

@@ -363,3 +363,3 @@ * @param {number} [options.speed=1.2] How fast animation occurs

bounds = LatLngBounds.convert(bounds);
bounds = LngLatBounds.convert(bounds);

@@ -402,3 +402,3 @@ var offset = Point.convert(options.offset),

if ('center' in options) {
tr.center = LatLng.convert(options.center);
tr.center = LngLat.convert(options.center);
}

@@ -468,4 +468,4 @@

scale = tr.zoomScale(zoom - startZoom),
to = 'center' in options ? tr.project(LatLng.convert(options.center)).sub(offset.div(scale)) : from,
around = LatLng.convert(options.around);
to = 'center' in options ? tr.project(LngLat.convert(options.center)).sub(offset.div(scale)) : from,
around = LngLat.convert(options.around);

@@ -555,3 +555,3 @@ if (zoom !== startZoom) {

var center = 'center' in options ? LatLng.convert(options.center) : this.getCenter();
var center = 'center' in options ? LngLat.convert(options.center) : this.getCenter();
var zoom = 'zoom' in options ? +options.zoom : startZoom;

@@ -558,0 +558,0 @@ var bearing = 'bearing' in options ? this._normalizeBearing(options.bearing, startBearing) : startBearing;

'use strict';
var DOM = require('../../util/dom'),
LatLngBounds = require('../../geo/lat_lng_bounds'),
LngLatBounds = require('../../geo/lng_lat_bounds'),
util = require('../../util/util');

@@ -65,3 +65,3 @@

p1 = DOM.mousePos(this._el, e),
bounds = new LatLngBounds(this._map.unproject(p0), this._map.unproject(p1));
bounds = new LngLatBounds(this._map.unproject(p0), this._map.unproject(p1));

@@ -68,0 +68,0 @@ this._finish();

@@ -20,4 +20,4 @@ 'use strict';

_onDblClick: function (e) {
this._map.zoomTo(Math.round(this._map.getZoom()) + 1, {around: e.latLng});
this._map.zoomTo(Math.round(this._map.getZoom()) + 1, {around: e.lngLat});
}
};

@@ -48,3 +48,3 @@ 'use strict';

this._map.jumpTo({
center: [+loc[1], +loc[2]],
center: [+loc[2], +loc[1]],
zoom: +loc[0],

@@ -51,0 +51,0 @@ bearing: +(loc[3] || 0)

@@ -25,3 +25,3 @@ 'use strict';

* @property {Point} point the pixel location of the event
* @property {LatLng} point the geographic location of the event
* @property {LngLat} lngLat the geographic location of the event
* @property {Event} originalEvent the original DOM event

@@ -37,3 +37,3 @@ */

* @property {Point} point the pixel location of the event
* @property {LatLng} point the geographic location of the event
* @property {LngLat} lngLat the geographic location of the event
* @property {Event} originalEvent the original DOM event

@@ -49,6 +49,15 @@ */

* @property {Point} point the pixel location of the event
* @property {LatLng} point the geographic location of the event
* @property {LngLat} lngLat the geographic location of the event
* @property {Event} originalEvent the original DOM event
*/
/**
* Load event. This event is emitted immediately after all necessary resources have been downloaded
* and the first visually complete rendering has occurred.
*
* @event load
* @memberof Map
* @type {Object}
*/
function Interaction(map) {

@@ -147,3 +156,3 @@ this._map = map;

this._map.fire(type, {
latLng: this._map.unproject(pos),
lngLat: this._map.unproject(pos),
point: pos,

@@ -150,0 +159,0 @@ originalEvent: e

@@ -19,4 +19,4 @@ 'use strict';

var Camera = require('./camera');
var LatLng = require('../geo/lat_lng');
var LatLngBounds = require('../geo/lat_lng_bounds');
var LngLat = require('../geo/lng_lat');
var LngLatBounds = require('../geo/lng_lat_bounds');
var Point = require('point-geometry');

@@ -50,3 +50,3 @@ var Attribution = require('./control/attribution');

* container: 'map',
* center: [37.772537, -122.420679],
* center: [-122.420679, 37.772537],
* zoom: 13,

@@ -65,5 +65,5 @@ * style: style_object,

if (options.maxBounds) {
var b = LatLngBounds.convert(options.maxBounds);
var b = LngLatBounds.convert(options.maxBounds);
this.transform.lngRange = [b.getWest(), b.getEast()];
this.transform.latRange = [b.getSouth(), b.getNorth()];
this.transform.lngRange = [b.getWest(), b.getEast()];
}

@@ -81,2 +81,3 @@

'_onSourceUpdate',
'_onWindowResize',
'update',

@@ -97,5 +98,3 @@ 'render'

if (typeof window !== 'undefined') {
window.addEventListener('resize', function () {
this.stop().resize().update();
}.bind(this), false);
window.addEventListener('resize', this._onWindowResize, false);
}

@@ -258,6 +257,6 @@

*
* @returns {LatLngBounds}
* @returns {LngLatBounds}
*/
getBounds: function() {
return new LatLngBounds(
return new LngLatBounds(
this.transform.pointLocation(new Point(0, 0)),

@@ -270,7 +269,7 @@ this.transform.pointLocation(this.transform.size));

*
* @param {LatLng} latlng
* @param {LngLat} lnglat
* @returns {Object} `x` and `y` coordinates
*/
project: function(latlng) {
return this.transform.locationPoint(LatLng.convert(latlng));
project: function(lnglat) {
return this.transform.locationPoint(LngLat.convert(lnglat));
},

@@ -282,3 +281,3 @@

* @param {Array<number>} point [x, y] pixel coordinates
* @returns {LatLng}
* @returns {LngLat}
*/

@@ -294,4 +293,4 @@ unproject: function(point) {

* @param {Object} params
* @param {number} [params.radius=0] Optional. Radius in pixels to search in
* @param {string} params.layer Optional. Only return features from a given layer
* @param {number} [params.radius=0] Radius in pixels to search in
* @param {string|Array<string>} [params.layer] Only return features from a given layer or layers
* @param {string} params.type Optional. Either `raster` or `vector`

@@ -313,3 +312,4 @@ * @param {boolean} [params.includeGeometry=false] Optional. If `true`, geometry of features will be included in the results at the expense of a much slower query time.

featuresAt: function(point, params, callback) {
var coord = this.transform.pointCoordinate(Point.convert(point));
var location = this.unproject(point).wrap();
var coord = this.transform.locationCoordinate(location);
this.style.featuresAt(coord, params, callback);

@@ -713,2 +713,5 @@ return this;

this.setStyle(null);
if (typeof window !== 'undefined') {
window.removeEventListener('resize', this._onWindowResize, false);
}
return this;

@@ -766,2 +769,6 @@ },

this._forwardSourceEvent(e);
},
_onWindowResize: function() {
this.stop().resize().update();
}

@@ -768,0 +775,0 @@ });

@@ -8,3 +8,3 @@ 'use strict';

var DOM = require('../util/dom');
var LatLng = require('../geo/lat_lng');
var LngLat = require('../geo/lng_lat');

@@ -19,3 +19,3 @@ /**

* var tooltip = new mapboxgl.Popup()
* .setLatLng(map.unproject(e.point))
* .setLngLat(e.lngLat)
* .setHTML("<h1>Hello World!</h1>")

@@ -76,6 +76,6 @@ * .addTo(map);

* Get the current coordinates of popup element relative to map
* @returns {LatLng}
* @returns {LngLat}
*/
getLatLng: function() {
return this._latLng;
getLngLat: function() {
return this._lngLat;
},

@@ -85,7 +85,7 @@

* Set the coordinates of a popup element to a map
* @param {LatLng} latlng
* @param {LngLat} lnglat
* @returns {Popup} `this`
*/
setLatLng: function(latlng) {
this._latLng = LatLng.convert(latlng);
setLngLat: function(lnglat) {
this._lngLat = LngLat.convert(lnglat);
this._update();

@@ -163,5 +163,5 @@ return this;

_updatePosition: function() {
if (!this._latLng || !this._container) { return; }
if (!this._lngLat || !this._container) { return; }
var pos = this._map.project(this._latLng).round(),
var pos = this._map.project(this._lngLat).round(),
anchor = this.options.anchor;

@@ -168,0 +168,0 @@

@@ -62,2 +62,4 @@ 'use strict';

data: png.data,
complete: true,
addEventListener: function() {},
getData: function() { return this.data; }

@@ -64,0 +66,0 @@ });

'use strict';
module.exports = {
HTTP_URL: 'http://a.tiles.mapbox.com',
HTTPS_URL: 'https://a.tiles.mapbox.com',
FORCE_HTTPS: true,
API_URL: 'https://api.mapbox.com',
REQUIRE_ACCESS_TOKEN: true
};

@@ -14,6 +14,3 @@ 'use strict';

var https = config.FORCE_HTTPS ||
(typeof document !== 'undefined' && document.location.protocol === 'https:');
url = url.replace(/^mapbox:\/\//, (https ? config.HTTPS_URL : config.HTTP_URL) + pathPrefix);
url = url.replace(/^mapbox:\/\//, config.API_URL + pathPrefix);
url += url.indexOf('?') !== -1 ? '&access_token=' : '?access_token=';

@@ -34,7 +31,10 @@

module.exports.normalizeStyleURL = function(url, accessToken) {
var user = url.match(/^mapbox:\/\/([^.]+)/);
if (!user)
if (!url.match(/^mapbox:\/\/styles\//))
return url;
return normalizeURL(url, '/styles/v1/' + user[1] + '/', accessToken);
var split = url.split('/');
var user = split[3];
var style = split[4];
var draft = split[5] ? '/draft' : '';
return normalizeURL('mapbox://' + user + '/' + style + draft, '/styles/v1/', accessToken);
};

@@ -46,10 +46,5 @@

url = normalizeURL(url + '.json', '/v4/', accessToken);
// TileJSON requests need a secure flag appended to their URLs so
// that the server knows to send SSL-ified resource references.
if (url.indexOf('https') === 0)
url += '&secure';
return url;
return normalizeURL(url + '.json', '/v4/', accessToken) + '&secure';
};

@@ -61,6 +56,15 @@

if (url.match(/^mapbox:\/\/fontstack/))
return normalizeURL(url, '/v4/', accessToken);
var user = url.split('/')[3];
return normalizeURL('mapbox://' + user + '/{fontstack}/{range}.pbf', '/fonts/v1/', accessToken);
};
return normalizeURL(url, '/', accessToken);
module.exports.normalizeSpriteURL = function(url, format, ext, accessToken) {
if (!url.match(/^mapbox:\/\/sprites\//))
return url + format + ext;
var split = url.split('/');
var user = split[3];
var style = split[4];
var draft = split[5] ? '/draft' : '';
return normalizeURL('mapbox://' + user + '/' + style + draft + '/sprite' + format + ext, '/styles/v1/', accessToken);
};

@@ -67,0 +71,0 @@

'use strict';
var UnitBezier = require('unitbezier');
var Coordinate = require('../geo/coordinate');

@@ -346,1 +347,27 @@ /**

};
/**
* Given a list of coordinates, get their center as a coordinate.
* @param {Array<Coordinate>} coords
* @returns {Coordinate} centerpoint
* @private
*/
exports.getCoordinatesCenter = function(coords) {
var minX = Infinity;
var minY = Infinity;
var maxX = -Infinity;
var maxY = -Infinity;
for (var i = 0; i < coords.length; i++) {
minX = Math.min(minX, coords[i].column);
minY = Math.min(minY, coords[i].row);
maxX = Math.max(maxX, coords[i].column);
maxY = Math.max(maxY, coords[i].row);
}
var dx = maxX - minX;
var dy = maxY - minY;
var dMax = Math.max(dx, dy);
return new Coordinate((minX + maxX) / 2, (minY + maxY) / 2, 0)
.zoomTo(Math.floor(-Math.log(dMax) / Math.LN2));
};
{
"name": "mapbox-gl",
"description": "A WebGL interactive maps library",
"version": "0.9.0",
"version": "0.10.0",
"main": "js/mapbox-gl.js",

@@ -20,3 +20,3 @@ "license": "BSD-3-Clause",

"mapbox-gl-function": "^1.0.0",
"mapbox-gl-style-spec": "^7.4.1",
"mapbox-gl-style-spec": "^8.0.1",
"minifyify": "^7.0.1",

@@ -41,3 +41,3 @@ "pbf": "^1.3.2",

"istanbul": "^0.3.15",
"mapbox-gl-test-suite": "git+https://github.com/mapbox/mapbox-gl-test-suite.git#b6b8a25e76231c2ceed341e024b4dce462c45a24",
"mapbox-gl-test-suite": "git+https://github.com/mapbox/mapbox-gl-test-suite.git#f21d42c120e7652252d39bf3d4eb4edd2f172dfb",
"mkdirp": "^0.5.1",

@@ -91,4 +91,4 @@ "prova": "^2.1.2",

"no-lonely-if": 2,
"no-else-return": 2,
"new-cap": 2,
"no-else-return": 0,
"new-cap": 0,
"no-empty": 2,

@@ -95,0 +95,0 @@ "no-new": 2,

@@ -10,4 +10,4 @@ [![Build Status](https://circleci.com/gh/mapbox/mapbox-gl-js.svg?style=svg)](https://circleci.com/gh/mapbox/mapbox-gl-js)

```html
<script src='https://api.tiles.mapbox.com/mapbox-gl-js/v0.9.0/mapbox-gl.js'></script>
<link href='https://api.tiles.mapbox.com/mapbox-gl-js/v0.9.0/mapbox-gl.css' rel='stylesheet' />
<script src='https://api.tiles.mapbox.com/mapbox-gl-js/v0.10.0/mapbox-gl.js'></script>
<link href='https://api.tiles.mapbox.com/mapbox-gl-js/v0.10.0/mapbox-gl.css' rel='stylesheet' />
```

@@ -14,0 +14,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc