Skip to content

Commit

Permalink
update changelog and readme [skip ci]
Browse files Browse the repository at this point in the history
- Document Node.js v0.12.x and io.js support
- Document map.release functionality.
- Add notes on garbage collection and request handling.
- Update binary platforms and build instructions.
- Document API token FileSource implementation from
  mapbox/mapbox-gl-native#1607
  • Loading branch information
mikemorris committed May 28, 2015
1 parent efb5831 commit c087981
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 5 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
# 1.1.0

- Adds Node.js v0.12.x and io.js support.
- Adds `map.release()` method for manual cleanup of map resources.
- Fixes garbage collection of NodeMap objects.
- Returns an error callback for failed NodeFileSource requests.
- Fixes handling of corrupt NodeFileSource request data.
- Updates build scripts and Travis CI configuration.
- Logs Environment ID and thread name when in an Environment scope.
- Refactors NodeLog to implement mbgl::Log::Observer.
- Fixes uncaught exception from missing sprites.
- Fixes Unicode glyph range end.

# 1.0.3

- Fixes crash during garbage collection by assigning FileSource handle to a v8::Persistent in NodeMap constructor.
Expand Down
45 changes: 40 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ Renders map tiles with [Mapbox GL](https://github.com/mapbox/mapbox-gl-native).
By default, installs binaries. On these platforms no external dependencies are needed.

- 64 bit OS X or 64 bit Linux
- Node v0.10.x
- Node.js v0.10.x, Node.js v0.12.x, io.js v2.x

Just run:

```
npm install mapbox-gl-native
```

However, other platforms will fall back to a source compile with `make build`. To compile this module, make sure all submodules are initialized.
However, other platforms will fall back to a source compile with `npm run build`. To compile this module, make sure all submodules are initialized with `git submodule update --init`.

## Rendering a map tile

Expand Down Expand Up @@ -46,6 +46,8 @@ The first argument passed to `map.render` is an options object, all keys are opt

_More about classes: https://github.com/mapbox/mapbox-gl-js/blob/master/API.md#working-with-style-classes_

When you are finished using a map object, you can call `map.release()` to dispose the internal map resources manually. This is not necessary, but can be helpful to optimize resource usage (memory, file sockets) on a more granualar level than v8's garbage collector.

## Testing

```
Expand Down Expand Up @@ -110,7 +112,7 @@ This is a very barebones implementation and you'll probably want a better implem
modified: new Date(),
expires: new Date(),
etag: "string",
data: new Buffer(),
data: new Buffer()
};
```

Expand Down Expand Up @@ -156,12 +158,45 @@ Note that in reality, Mapbox GL uses two types of protocols: `asset://` for file

## Mapbox API Access tokens

To use styles that rely on Mapbox vector tiles, you must register a [API access token](https://www.mapbox.com/developers/api/#access-tokens) on the map. Use the `setAccessToken` method before load:
To use styles that rely on Mapbox vector tiles, you must pass an [API access token](https://www.mapbox.com/developers/api/#access-tokens) in your `FileSource` implementation with requests to `mapbox://` protocols.

```js
var mbgl = require('mapbox-gl-native');
var request = require('request');
var url = require('url');

var fileSource = new mbgl.FileSource();
fileSource.request = function(req) {
var opts = {
url: req.url,
encoding: null,
gzip: true
};

if (url.parse(req.url).protocol === 'mapbox:') {
opts.qs = { access_token: process.env.MAPBOX_ACCESS_TOKEN};
}

request(opts, function (err, res, body) {
if (err) {
req.respond(err);
} else if (res.statusCode == 200) {
var response = {};

if (res.headers.modified) { response.modified = new Date(res.headers.modified); }
if (res.headers.expires) { response.expires = new Date(res.headers.expires); }
if (res.headers.etag) { response.etag = res.headers.etag; }
response.data = body;
req.respond(null, response);
} else {
req.respond(new Error(JSON.parse(body).message));
}
});
}

var map = mbgl.Map(fileSource);
var style = mapboxStyle; // includes a datasource with a reference to something like `mapbox://mapbox.mapbox-streets-v6`
map.setAccessToken(process.env.MAPBOX_ACCESS_TOKEN);

map.load(style);
map.render({}, function(err, image) {
if (err) throw err;
Expand Down

0 comments on commit c087981

Please sign in to comment.