Skip to content
This repository has been archived by the owner on Apr 24, 2024. It is now read-only.

Commit

Permalink
Merge pull request #1167 from mapbox/v3
Browse files Browse the repository at this point in the history
v3: Update Leaflet dependency to v1.0.1
  • Loading branch information
tmcw committed Oct 21, 2016
2 parents 9d45597 + ce1b461 commit eb5eab2
Show file tree
Hide file tree
Showing 15 changed files with 336 additions and 448 deletions.
35 changes: 1 addition & 34 deletions API.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ interactivity.
| ---- | ---- | ---- |
| element (_required_) | string | Must be the id of an element, or a DOM element reference. |
| id _or_ url _or_ tilejson | __string__ if _id_ or _url_ __object__ if _tilejson_ | url can be <ul><li>A map `id` string `examples.map-foo`</li><li>A comma separated list of map `id` strings `examples.map-foo,examples.map-bar` [example](https://www.mapbox.com/mapbox.js/example/v1.0.0/compositing/)</li><li>A URL to TileJSON, like `{{site.tileApi}}/v3/mapbox.dark.json`</li><li>A [TileJSON](https://www.mapbox.com/developers/tilejson/) object, from your own Javascript code</li></ul> |
| options | object | If provided, it is the same options as provided to L.Map with the following additions: <ul><li>`tileLayer` L.TileLayer options. Options passed to a `L.mapbox.tileLayer` based on the TileJSON. Set to `false` to disable the `L.mapbox.tileLayer`.</li><li>`featureLayer` `L.mapbox.featureLayer` options. Options passed to a `L.mapbox.featureLayer` based on the TileJSON. Set to `false` to disable the `L.mapbox.featureLayer`.</li><li>`gridLayer` `L.mapbox.gridLayer`. Options passed to a `L.mapbox.gridLayer` based on the TileJSON. Set to `false` to disable the `L.mapbox.gridLayer`.</li><li>`legendControl` `L.mapbox.legendControl` options. Options passed to a `L.mapbox.legendControl` based on the TileJSON. Set to `false` to disable the `L.mapbox.legendControl`.</li><li>`shareControl`: Options passed to a `L.mapbox.shareControl`. Set to `true` to enable the `L.mapbox.shareControl`.</li><li>`infoControl`: Options passed to a `L.mapbox.infoControl`. Set to `true` to enable the `L.mapbox.infoControl`.</li><li>`accessToken`: Mapbox API access token. Overrides `L.mapbox.accessToken` for this map.</li><li>`attributionControl`: value can be `{compact: true}` to force a compact attribution icon that shows the full attribution on click, or `{compact: false}` to force the full attribution control. The default is a responsive attribution that collapses when the map is less than 640 pixels wide.</li> |
| options | object | If provided, it is the same options as provided to L.Map with the following additions: <ul><li>`tileLayer` L.TileLayer options. Options passed to a `L.mapbox.tileLayer` based on the TileJSON. Set to `false` to disable the `L.mapbox.tileLayer`.</li><li>`featureLayer` `L.mapbox.featureLayer` options. Options passed to a `L.mapbox.featureLayer` based on the TileJSON. Set to `false` to disable the `L.mapbox.featureLayer`.</li><li>`gridLayer` `L.mapbox.gridLayer`. Options passed to a `L.mapbox.gridLayer` based on the TileJSON. Set to `false` to disable the `L.mapbox.gridLayer`.</li><li>`legendControl` `L.mapbox.legendControl` options. Options passed to a `L.mapbox.legendControl` based on the TileJSON. Set to `false` to disable the `L.mapbox.legendControl`.</li><li>`shareControl`: Options passed to a `L.mapbox.shareControl`. Set to `true` to enable the `L.mapbox.shareControl`.</li><li>`accessToken`: Mapbox API access token. Overrides `L.mapbox.accessToken` for this map.</li><li>`attributionControl`: value can be `{compact: true}` to force a compact attribution icon that shows the full attribution on click, or `{compact: false}` to force the full attribution control. The default is a responsive attribution that collapses when the map is less than 640 pixels wide.</li> |

_Example_:

Expand Down Expand Up @@ -391,39 +391,6 @@ _Returns_: the geocoder object. The return value of this function is not useful

# Controls

## L.mapbox.infoControl(options)

<span class='leaflet icon'>_Extends_: `L.Control`</span>

A map control that shows a toggleable info container. If set, attribution is auto-detected from active layers and added to the info container.

| Options | Value | Description |
| ---- | ---- | ---- |
| options _optional_ | object | An options object. Beyond the default options for map controls, this object has a one additional parameter: <ul><li>`sanitizer`: A function that accepts a string, and returns a sanitized result for HTML display. The default will remove dangerous script content, and is recommended.</li></ul> |

_Example_:

var map = L.mapbox.map('map').setView([38, -77], 5);
map.addControl(L.mapbox.infoControl().addInfo('foo'));

_Returns_: a `L.mapbox.infoControl` object.

_Class_: `L.mapbox.InfoControl`

### infoControl.addInfo(info)
Adds an info string to infoControl.

| Options | Value | Description |
| ---- | ---- | ---- |
| info _required_ | string | A string which may contain HTML. It will be sanitized by the infoControl's sanitizer option. |

### infoControl.removeInfo(info)
Removes an info string from infoControl.

| Options | Value | Description |
| ---- | ---- | ---- |
| info _required_ | string | Info to remove. |

## L.mapbox.legendControl(options)

<span class='leaflet icon'>_Extends_: L.Control</span>
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## v3.0.0

* Upgrades Leaflet dependency to v1.0.1
* Removes the deprecated `InfoControl` class.

## v2.4.0

* Adds `autocomplete` and `country` options to the `L.mapbox.geocoder`
Expand Down
9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"author": "Mapbox",
"name": "mapbox.js",
"description": "mapbox javascript api",
"version": "2.4.0",
"version": "3.0.0-beta",
"homepage": "http://mapbox.com/",
"repository": {
"type": "git",
Expand All @@ -12,16 +12,17 @@
"dependencies": {
"corslite": "0.0.6",
"isarray": "0.0.1",
"leaflet": "0.7.7",
"leaflet": "1.0.1",
"mustache": "2.2.1",
"sanitize-caja": "0.1.4"
},
"scripts": {
"test": "eslint --no-eslintrc -c .eslintrc src && mocha-phantomjs test/index.html"
"test": "eslint --no-eslintrc -c .eslintrc src && phantomjs node_modules/mocha-phantomjs-core/mocha-phantomjs-core.js test/index.html"
},
"license": "BSD-3-Clause",
"devDependencies": {
"browserify": "^13.0.0",
"phantomjs-prebuilt": "2.1.12",
"clean-css": "~2.0.7",
"eslint": "^0.23.0",
"expect.js": "0.3.1",
Expand All @@ -32,7 +33,7 @@
"minifyify": "^6.1.0",
"minimist": "0.0.5",
"mocha": "2.4.5",
"mocha-phantomjs": "4.0.2",
"mocha-phantomjs-core": "2.0.1",
"sinon": "1.10.2"
},
"optionalDependencies": {},
Expand Down
4 changes: 3 additions & 1 deletion src/feature_layer.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,9 @@ var FeatureLayer = L.FeatureGroup.extend({
pointToLayer = this.options.pointToLayer || function(feature, latlon) {
return marker.style(feature, latlon, opts);
},
layer = L.GeoJSON.geometryToLayer(json, pointToLayer),
layer = L.GeoJSON.geometryToLayer(json, {
pointToLayer: pointToLayer
}),
popupHtml = marker.createPopup(json, this.options.sanitizer),
style = this.options.style,
defaultStyle = style === simplestyle.style;
Expand Down
9 changes: 2 additions & 7 deletions src/grid_layer.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ var util = require('./util'),
grid = require('./grid');

// forked from danzel/L.UTFGrid
var GridLayer = L.Class.extend({
includes: [L.Mixin.Events, require('./load_tilejson')],
var GridLayer = L.Layer.extend({
includes: [require('./load_tilejson')],

options: {
template: function() { return ''; }
Expand Down Expand Up @@ -46,11 +46,6 @@ var GridLayer = L.Class.extend({
return !!(this._map && this.options.grids && this.options.grids.length);
},

addTo: function (map) {
map.addLayer(this);
return this;
},

onAdd: function(map) {
this._map = map;
this._update();
Expand Down
115 changes: 0 additions & 115 deletions src/info_control.js

This file was deleted.

16 changes: 0 additions & 16 deletions src/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ var tileLayer = require('./tile_layer').tileLayer,
featureLayer = require('./feature_layer').featureLayer,
gridLayer = require('./grid_layer').gridLayer,
gridControl = require('./grid_control').gridControl,
infoControl = require('./info_control').infoControl,
shareControl = require('./share_control').shareControl,
legendControl = require('./legend_control').legendControl,
mapboxLogoControl = require('./mapbox_logo').mapboxLogoControl,
Expand All @@ -25,7 +24,6 @@ var LMap = L.Map.extend({
gridLayer: {},
legendControl: {},
gridControl: {},
infoControl: false,
shareControl: false,
sanitizer: require('sanitize-caja')
},
Expand Down Expand Up @@ -82,11 +80,6 @@ var LMap = L.Map.extend({
this.addControl(this.gridControl);
}

if (this.options.infoControl) {
this.infoControl = infoControl(this.options.infoControl);
this.addControl(this.infoControl);
}

if (this.options.legendControl) {
this.legendControl = legendControl(this.options.legendControl);
this.addControl(this.legendControl);
Expand Down Expand Up @@ -142,11 +135,6 @@ var LMap = L.Map.extend({
this._updateLayer(this.gridLayer);
}

if (this.infoControl && json.attribution) {
this.infoControl.addInfo(this.options.sanitizer(json.attribution));
this._updateMapFeedbackLink();
}

if (this.legendControl && json.legend) {
this.legendControl.addLegend(json.legend);
}
Expand Down Expand Up @@ -209,10 +197,6 @@ var LMap = L.Map.extend({
_updateLayer: function(layer) {
if (!layer.options) return;

if (this.infoControl && this._loaded) {
this.infoControl.addInfo(layer.options.infoControl);
}

if (this.attributionControl && this._loaded && layer.getAttribution) {
this.attributionControl.addAttribution(layer.getAttribution());
}
Expand Down
3 changes: 0 additions & 3 deletions src/mapbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ var geocoderControl = require('./geocoder_control'),
legendControl = require('./legend_control'),
shareControl = require('./share_control'),
tileLayer = require('./tile_layer'),
infoControl = require('./info_control'),
map = require('./map'),
gridLayer = require('./grid_layer'),
styleLayer = require('./style_layer');
Expand All @@ -20,8 +19,6 @@ L.mapbox = module.exports = {
TileLayer: tileLayer.TileLayer,
styleLayer: styleLayer.styleLayer,
StyleLayer: styleLayer.StyleLayer,
infoControl: infoControl.infoControl,
InfoControl: infoControl.InfoControl,
shareControl: shareControl.shareControl,
ShareControl: shareControl.ShareControl,
legendControl: legendControl.legendControl,
Expand Down
7 changes: 1 addition & 6 deletions test/manual/share_control.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,7 @@
<div id='map'>
</div>
<script>
var map = L.mapbox.map('map', 'tristen.map-ixqro653', {
infoControl: {
position: 'bottomright',
editLink: true
}
})
var map = L.mapbox.map('map', 'tristen.map-ixqro653')
.addControl(L.mapbox.shareControl());
</script>
</body>
Expand Down
3 changes: 1 addition & 2 deletions test/manual/standalone.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@
<html>
<head>
<meta charset='UTF-8'/>
<link rel='stylesheet' href='http://cdn.leafletjs.com/leaflet-0.6/leaflet.css' />
<script src='https://unpkg.com/leaflet@1.0.1/dist/leaflet.js'></script>
<link rel='stylesheet' href='../../dist/mapbox.standalone.css'/>
<link rel='stylesheet' href='embed.css'/>
<script src='http://cdn.leafletjs.com/leaflet-0.6/leaflet.js'></script>
<script src='../../dist/mapbox.standalone.js'></script>
<script src='access_token.js'></script>
</head>
Expand Down
4 changes: 0 additions & 4 deletions test/manual/theme.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,6 @@
.addControl(L.mapbox.shareControl())
.setView([37.9, -77], 5);

var info = L.mapbox.infoControl({
position: 'bottomleft'
}).addInfo('foo').addTo(mapdark);

var feature = {
type: 'Feature',
geometry: {
Expand Down
2 changes: 1 addition & 1 deletion test/spec/feature_layer.js
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,6 @@ describe('L.mapbox.featureLayer', function() {
}),
marker = layer.getLayers()[0];

expect(marker instanceof L.Circle).to.equal(true);
expect(marker instanceof L.CircleMarker).to.equal(true);
});
});
Loading

0 comments on commit eb5eab2

Please sign in to comment.