Skip to content

Commit

Permalink
Added documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
timanrebel committed Jun 14, 2016
1 parent c3909d0 commit 66cb206
Show file tree
Hide file tree
Showing 5 changed files with 546 additions and 1 deletion.
38 changes: 37 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,40 @@
Mapbox Appcelerator Titanium module
===========================================

Work in progress. Not for production use!
The goal for this module is to support the complete and latest version of the Mapbox SDK.

## Documentation

Documentation for this module can be found in the [documentation](https://github.com/MatiseAms/ti-mapbox-gl/blob/master/documentation/index.md) folder

## Changelog

* [1.0.0](https://github.com/MatiseAms/ti-mapbox-gl/releases/tag/1.0.0) Initial working version with custom maps, annotations and GeoJSON routes.

## Author

Timan Rebel

## License

The MIT License (MIT)

Copyright (c) 2014 Timan Rebel

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
29 changes: 29 additions & 0 deletions documentation/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Mapbox Module

The goal of this module is to support as much as possible of the latest Mapbox SDK.

## Quick Start

### Get it
Download the latest zip file from [Releases](https://github.com/MatiseAms/ti-mapbox-gl/releases) and consult the [Titanium Documentation](http://docs.appcelerator.com/titanium/latest/#!/guide/Using_a_Module) on how install it.

Besides installing the module, for iOS it is also needed to download the plugin and install it. This can be done by cpoying the `ti.dynamiclib` folder to the plugins folder and add the plugin to the `tiapp.xml` file.

## Accessing the Mapbox Module

To access this module from JavaScript, you would do the following:

`var mapbox = require('matise.mapbox');`


The `mapbox` variable is a reference to the Module object.

## Reference

The documentation is split up in the following sections:

* TODO, please see the app.js example.

## Building new version

When updating the iOS Mapbox SDK it is important to run the `strip.sh` script in the `iphone` directory to generate a stripped framework for AdHoc and AppStore distribution. The dynamic library contains i386 and x64 archs which are not allowed to upload to the AppStore. The original framework is copied to both `platform` and zplatform/simz. The `strip.sh` creates a stripped version in `platform/appstore`. The `ti.dynamiclib.js` plugin than copies the correct framework during the build process to make sure the right framework is used.
64 changes: 64 additions & 0 deletions example/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
var win = Ti.UI.createWindow({
backgroundColor: 'white'
});

var Mapbox = require('matise.mapbox');
var mapview = Mapbox.createMapView({
styleUrl: "<your style url>",
lat: 53.034413561940354,
lng: 4.838747978210449,
zoom: 12,
// Only used on Android
onMapReady: onMapReady,

height: '50%',
bottom: 0
});

// Add geojson
var file = Ti.Filesystem.getFile(Ti.Filesystem.resourcesDirectory, "geo.geojson");
var blob = file.read();
var geoJSON = blob.text;

if(OS_IOS)
onMapReady();

function onMapReady() {
// Add marker
var marker = Mapbox.createPointAnnotation({
lat: 53.039316519775205,
lng: 4.84801081161499,
title: 'Hello',
subtitle: 'Marker1',
image: "marker.png"
});

var marker2 = Mapbox.createPointAnnotation({
lat: 53.039316519775205,
lng: 4.83801081161499,
title: 'Hello',
subtitle: 'Marker2',
image: "marker.png"
});

mapview.addAnnotation(marker);
mapview.addAnnotation(marker2);

setTimeout(function() {
// On iOS the SDK does not support changing annotations, so they need to be removed and then re-added instead.
OS_IOS && mapview.removeAnnotation(marker);

marker.setCoordinate({
lat: 53.029316519775205,
lng: 4.83801081161499
});

// On iOS the SDK does not support changing annotations, so they need to be removed and then re-added instead.
OS_IOS && mapview.addAnnotation(marker);
}, 2000);

mapview.drawPolyline(geoJSON);
}

win.add(mapview);
win.open();
Loading

0 comments on commit 66cb206

Please sign in to comment.