Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] MapboxGL Android 4.x.x #22

Open
wants to merge 37 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
1dffe28
Initial steps to cleanup plugin and encapsulate map instances.
tnightingale Mar 17, 2016
34a5a54
Added js bindings for new map instance. Rearranged MapView & MapboxMa…
tnightingale Mar 17, 2016
20cf01b
Added service MapboxSDK depends on. Added a Mapbox.create API
tnightingale Mar 18, 2016
881cb4c
fixing issue with accessing view from non-ui thread.
tnightingale Mar 18, 2016
d1a25e6
Fleshing out new instance API.
tnightingale Mar 18, 2016
0fb3d2a
Cleaning up map creation API, particularly options processing/handling.
tnightingale Mar 18, 2016
36cc052
Added support for permission requests via command pattern. Implemente…
tnightingale Mar 18, 2016
961c4d9
Attempt at matching mapbox-gl-js api.
tnightingale Mar 21, 2016
cbe2269
adding assign function (based on Object.assign polyfill from MDN).
tnightingale Mar 21, 2016
47b7373
Implemented jumpTo() from mapbox-gl-js api.
tnightingale Mar 21, 2016
cb505f4
Fixed thread issue with setUserLocation().
tnightingale Mar 21, 2016
df8d69b
Cleaning up file layout.
tnightingale Mar 21, 2016
864084a
initial offline pieces
tnightingale Mar 22, 2016
846b174
Offline implementation independenant of map instances.
tnightingale Mar 22, 2016
3dd2ad6
Offline regions.
tnightingale Mar 22, 2016
9b003e8
Added some todo notes.
tnightingale Mar 23, 2016
77ec663
Fixing up complete and error callbacks
tnightingale Mar 23, 2016
2c55732
fixing complete and error callbacks.
tnightingale Mar 24, 2016
9452eb0
fixing multiple complete callback issue and cordova freezing issue
tnightingale Mar 24, 2016
af2e379
removing debug statments
tnightingale Mar 24, 2016
527f68c
Updated debug statements.
tnightingale Mar 24, 2016
b42a016
Implemented Android lifecycle methods.
tnightingale Mar 24, 2016
a95a490
Implmented loadOfflineRegions()
tnightingale Mar 25, 2016
96e29b9
implemented region status
tnightingale Mar 25, 2016
ff8b3f4
fixed issue where no style was set when offline.
tnightingale Mar 25, 2016
331c533
updating to 4.0.0-rc.1
tnightingale Mar 26, 2016
67e8736
Added example of proposed javascript api
tnightingale Mar 26, 2016
26c5192
Moving static Map instance management into domain of mapboxManager.
tnightingale Mar 27, 2016
3b4607f
fixing chicken and egg issue with map and mapview creation.
tnightingale Mar 27, 2016
d9031e1
Added initial geojson support with js api that matches mapbox-gl-js.
tnightingale Mar 27, 2016
b8561db
Added promise support to API.
tnightingale Mar 27, 2016
563e715
Fixes bunch of issues with offline layer loading.
tnightingale Mar 28, 2016
857674a
switched downloading log statements to debug
tnightingale Mar 29, 2016
d0f5b03
Removed calls to MapView's onStart() and onStop() as they have been r…
tnightingale Mar 29, 2016
db2154a
Cleaned up OfflineRegion implementation. Removed extra call to Androi…
tnightingale Mar 30, 2016
efd96e6
Initial attempt at supporting ALL map events.
tnightingale Mar 30, 2016
d4125fe
Added initial attempt at map events.
tnightingale Mar 31, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 87 additions & 0 deletions demo/mapboxgl-android-4.x.x-example.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
var cabo = {
name: "Cabo San Lucas",
style: "emerald",
minZoom: 0,
maxZoom: 16,
bounds: {
north: 22.891,
east: -109.919,
south: 22.879,
west: -109.905
}
};

Mapbox.listOfflineRegions(function (err, regions) {
if (err) return onError(err);
console.log('listOfflineRegions()', regions);

var region = regions[cabo.name];

// First load will download region.
if (!region) {
region = Mapbox.createOfflineRegion(cabo);

region.on("error", function (e) {
console.error("OfflineRegion onError", e);
});

region.on("progress", function (progress) {
console.log("OfflineRegion download onProgress", progress);
});

region.on("complete", function (progress) {
console.log("OfflineRegion download onComplete", progress);
});

region.download();
}
// Subsequent loads will display offline region download status.
else {
region.getStatus(function (err, status) {
if (err) return onError(err);
console.log("OfflineRegion getStatus()", status);
});
}
});

var map = new Mapbox.Map({
style: 'emerald',
zoom: 15,
center: [-109.912, 22.885],
showUserLocation: true,
margins: {
left: 0,
right: 0,
top: 0,
bottom: 0
},
markers: [
{"title": "Marker 1", "lng": -109.912, "lat": 22.885}
],
// NOTE: the options below are broken...
hideAttribution: true, // default false
hideLogo: true, // default false
hideCompass: false, // default false
disableRotation: false, // default false
disableScroll: false, // default false
disableZoom: false, // default false
disablePitch: false // default false
});

map.on('load', function (e) {
map.addMarkers(
[
{"title": "Marker 2", "lng": -109.910, "lat": 22.886},
{"title": "Marker 3", "lng": -109.913, "lat": 22.883}
],
function () { console.log("Markers added!"); },
function (e) { console.error("Error adding markers:", e); }
);

map.addMarkerCallback(printMarker);

function printMarker(selectedMarker) {
alert("Marker selected: " + JSON.stringify(selectedMarker));
map.addMarkerCallback(printMarker);
}
});
20 changes: 19 additions & 1 deletion plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,15 @@
<engine name="cordova-plugman" version=">=4.2.0"/><!-- needed for gradleReference support -->
</engines>

<js-module src="www/mixin.js" name="mixin" />
<js-module src="www/mapbox-plugin-api-mixin.js" name="mapbox-plugin-api-mixin" />
<js-module src="www/events-mixin.js" name="events-mixin" />
<js-module src="www/map-events.js" name="map-events" />
<js-module src="www/map-instance.js" name="map-instance" />
<js-module src="www/offline-region.js" name="offline-region" />

<js-module src="www/Mapbox.js" name="Mapbox">
<clobbers target="Mapbox" />
<clobbers target="window.Mapbox" />
</js-module>

<!-- android -->
Expand All @@ -46,8 +53,19 @@
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
</config-file>

<config-file target="AndroidManifest.xml" parent="/manifest/application">
<service android:name="com.mapbox.mapboxsdk.telemetry.TelemetryService" />
</config-file>

<framework src="src/android/mapbox.gradle" custom="true" type="gradleReference"/>
<framework src="com.android.support:appcompat-v7:22.+" />
<source-file src="src/android/Mapbox.java" target-dir="src/com/telerik/plugins/mapbox"/>
<source-file src="src/android/MapboxManager.java" target-dir="src/com/telerik/plugins/mapbox"/>
<source-file src="src/android/OfflineRegion.java" target-dir="src/com/telerik/plugins/mapbox"/>
<source-file src="src/android/Map.java" target-dir="src/com/telerik/plugins/mapbox"/>
<source-file src="src/android/FeatureManager.java" target-dir="src/com/telerik/plugins/mapbox"/>
<source-file src="src/android/GeoJSONMarker.java" target-dir="src/com/telerik/plugins/mapbox"/>
<source-file src="src/android/GeoJSONMarkerOptions.java" target-dir="src/com/telerik/plugins/mapbox"/>

<!-- This leads to trouble in AppBuilder when compiling for Cordova-Android 4 -->
<!--source-file src="src/android/res/values/mapboxstrings.xml" target-dir="res/values" />
Expand Down
Loading