Skip to content

Commit

Permalink
#44 Enhancement: expose other methods to XML map
Browse files Browse the repository at this point in the history
  • Loading branch information
EddyVerbruggen committed Oct 25, 2016
1 parent fc3e735 commit c07ee44
Show file tree
Hide file tree
Showing 5 changed files with 288 additions and 157 deletions.
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,11 @@ function onMapReady(args) {
exports.onMapReady = onMapReady;
```

Note that at the moment these are the only two of the methods listed below
you can use with the XML-rendered map API. It's very easy to add other methods though,
so please open an issue on GitHub if you need to fi get the zoom level in a similar way.
Other methods you can invoke like this from an XML-declared map are:
`removeMarkers`, `setCenter`, `setZoomLevel`, `setViewport`, `setTilt`,
`animateCamera`, `addPolygon` and `addPolyline`.

Check out the usage details on the functions below.

## Declaring a map programmatically

Expand Down
28 changes: 28 additions & 0 deletions mapbox-common.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,38 @@ var Mapbox = (function (_super) {
mapbox.addMarkers(args, this.native);
};

Mapbox.prototype.removeMarkers = function (args) {
mapbox.removeMarkers(args, this.native);
};

Mapbox.prototype.setCenter = function (args) {
mapbox.setCenter(args, this.native);
};

Mapbox.prototype.setZoomLevel = function (args) {
mapbox.setZoomLevel(args, this.native);
};

Mapbox.prototype.setViewport = function (args) {
mapbox.setViewport(args, this.native);
};

Mapbox.prototype.setTilt = function (args) {
mapbox.setTilt(args, this.native);
};

Mapbox.prototype.animateCamera = function (args) {
mapbox.animateCamera(args, this.native);
};

Mapbox.prototype.addPolygon = function (args) {
mapbox.addPolygon(args, this.native);
};

Mapbox.prototype.addPolyline = function (args) {
mapbox.addPolyline(args, this.native);
};

// properties that can be set from XML
Object.defineProperty(Mapbox.prototype, "accessToken", {
set: function (value) {
Expand Down
Loading

0 comments on commit c07ee44

Please sign in to comment.