Merge remote-tracking branch 'mapbox/master' into 2317-espresso
Conflicts: android/java/MapboxGLAndroidSDKTestApp/build.gradle
6
.gitignore
vendored
@@ -12,11 +12,14 @@
|
||||
/mason_packages
|
||||
/config/*.gypi
|
||||
/build
|
||||
/lib
|
||||
/macosx/build
|
||||
/linux/build
|
||||
/ios/build
|
||||
/ios/app/build
|
||||
/test/build
|
||||
/gyp/build
|
||||
/gyp/java
|
||||
/test/node_modules
|
||||
/test/fixtures/*/*_actual.*
|
||||
/test/fixtures/api/1.png
|
||||
@@ -31,3 +34,6 @@
|
||||
/ios/benchmark/assets/tiles/mapbox.mapbox-streets-v6/
|
||||
/ios/benchmark/assets/tiles/mapbox.mapbox-terrain-v2/
|
||||
/ios/benchmark/assets/glyphs/DIN Offc Pro*/
|
||||
|
||||
/platform/node/test/actual
|
||||
/platform/node/test/diff
|
||||
|
||||
4
.gitmodules
vendored
@@ -1,7 +1,3 @@
|
||||
[submodule "test/suite"]
|
||||
path = test/suite
|
||||
url = https://github.com/mapbox/mapbox-gl-test-suite.git
|
||||
|
||||
[submodule ".mason"]
|
||||
path = .mason
|
||||
url = https://github.com/mapbox/mason.git
|
||||
|
||||
43
.travis.yml
@@ -25,46 +25,69 @@ matrix:
|
||||
sources: [ 'ubuntu-toolchain-r-test', 'llvm-toolchain-precise-3.5' ]
|
||||
packages: [ 'gdb', 'clang-3.5', 'libstdc++-4.9-dev', 'libstdc++6', 'libllvm3.4', 'xutils-dev', 'libxxf86vm-dev', 'x11proto-xf86vidmode-dev', 'mesa-utils' ]
|
||||
- os: osx
|
||||
osx_image: beta-xcode6.3
|
||||
osx_image: xcode6.4
|
||||
env: FLAVOR=osx BUILDTYPE=Debug
|
||||
- os: osx
|
||||
osx_image: beta-xcode6.3
|
||||
osx_image: xcode6.4
|
||||
env: FLAVOR=ios BUILDTYPE=Release
|
||||
- os: linux
|
||||
env: FLAVOR=android ANDROID_ABI=arm-v7 BUILDTYPE=Release
|
||||
android:
|
||||
components: [ 'build-tools-22.0.1', 'android-22', 'extra' ]
|
||||
components: [ 'build-tools-23.0.1', 'android-23', 'extra-android-m2repository', 'extra-android-support', 'extra-google-m2repository' ]
|
||||
addons:
|
||||
apt:
|
||||
packages: [ 'lib32stdc++6' ]
|
||||
- os: linux
|
||||
env: FLAVOR=android ANDROID_ABI=arm-v7 BUILDTYPE=Debug
|
||||
android:
|
||||
components: [ 'build-tools-22.0.1', 'android-22', 'extra' ]
|
||||
components: [ 'build-tools-23.0.1', 'android-23', 'extra-android-m2repository', 'extra-android-support', 'extra-google-m2repository' ]
|
||||
addons:
|
||||
apt:
|
||||
packages: [ 'lib32stdc++6' ]
|
||||
- os: linux
|
||||
env: FLAVOR=android ANDROID_ABI=arm-v8 BUILDTYPE=Release
|
||||
android:
|
||||
components: [ 'build-tools-22.0.1', 'android-22', 'extra' ]
|
||||
components: [ 'build-tools-23.0.1', 'android-23', 'extra-android-m2repository', 'extra-android-support', 'extra-google-m2repository' ]
|
||||
addons:
|
||||
apt:
|
||||
packages: [ 'lib32stdc++6' ]
|
||||
- os: linux
|
||||
env: FLAVOR=android ANDROID_ABI=x86 BUILDTYPE=Release
|
||||
android:
|
||||
components: [ 'build-tools-22.0.1', 'android-22', 'extra' ]
|
||||
components: [ 'build-tools-23.0.1', 'android-23', 'extra-android-m2repository', 'extra-android-support', 'extra-google-m2repository' ]
|
||||
addons:
|
||||
apt:
|
||||
packages: [ 'lib32stdc++6' ]
|
||||
- os: linux
|
||||
env: FLAVOR=android ANDROID_ABI=mips BUILDTYPE=Release
|
||||
android:
|
||||
components: [ 'build-tools-22.0.1', 'android-22', 'extra' ]
|
||||
env: FLAVOR=node CXX=clang++-3.5 BUILDTYPE=Release NODE_VERSION=iojs-v3
|
||||
addons:
|
||||
apt:
|
||||
packages: [ 'lib32stdc++6' ]
|
||||
sources: [ 'ubuntu-toolchain-r-test', 'llvm-toolchain-precise-3.5' ]
|
||||
packages: [ 'gdb', 'clang-3.5', 'libstdc++-4.9-dev', 'libstdc++6', 'libllvm3.4', 'xutils-dev', 'libxxf86vm-dev', 'x11proto-xf86vidmode-dev', 'mesa-utils' ]
|
||||
- os: linux
|
||||
env: FLAVOR=node CXX=clang++-3.5 BUILDTYPE=Release NODE_VERSION=0.12
|
||||
addons:
|
||||
apt:
|
||||
sources: [ 'ubuntu-toolchain-r-test', 'llvm-toolchain-precise-3.5' ]
|
||||
packages: [ 'gdb', 'clang-3.5', 'libstdc++-4.9-dev', 'libstdc++6', 'libllvm3.4', 'xutils-dev', 'libxxf86vm-dev', 'x11proto-xf86vidmode-dev', 'mesa-utils' ]
|
||||
- os: linux
|
||||
env: FLAVOR=node CXX=clang++-3.5 BUILDTYPE=Release NODE_VERSION=0.10
|
||||
addons:
|
||||
apt:
|
||||
sources: [ 'ubuntu-toolchain-r-test', 'llvm-toolchain-precise-3.5' ]
|
||||
packages: [ 'gdb', 'clang-3.5', 'libstdc++-4.9-dev', 'libstdc++6', 'libllvm3.4', 'xutils-dev', 'libxxf86vm-dev', 'x11proto-xf86vidmode-dev', 'mesa-utils' ]
|
||||
- os: osx
|
||||
osx_image: xcode6.4
|
||||
compiler: clang
|
||||
env: FLAVOR=node NODE_VERSION=iojs-v3
|
||||
- os: osx
|
||||
osx_image: xcode6.4
|
||||
compiler: clang
|
||||
env: FLAVOR=node NODE_VERSION=0.12
|
||||
- os: osx
|
||||
osx_image: xcode6.4
|
||||
compiler: clang
|
||||
env: FLAVOR=node NODE_VERSION=0.10
|
||||
|
||||
env:
|
||||
global:
|
||||
|
||||
@@ -80,14 +80,18 @@ def MakeRelativePathsInFlagsAbsolute(flags, working_directory):
|
||||
return new_flags
|
||||
|
||||
|
||||
def FlagsForFileDefault():
|
||||
return {
|
||||
'flags': default_flags,
|
||||
'do_cache': False,
|
||||
}
|
||||
|
||||
|
||||
def FlagsForFileLinux(filename):
|
||||
working_directory = os.path.join('build', 'linux')
|
||||
|
||||
if not os.path.exists(os.path.join(DirectoryOfThisScript(), working_directory)):
|
||||
return {
|
||||
'flags': default_flags,
|
||||
'do_cache': False,
|
||||
}
|
||||
return FlagsForFileDefault()
|
||||
|
||||
relative_source_path = filename.replace(DirectoryOfThisScript() + '/', '')
|
||||
relative_obj_path = os.path.splitext(relative_source_path)[0] + '.o'
|
||||
@@ -98,10 +102,7 @@ def FlagsForFileLinux(filename):
|
||||
stdout, stderr = p.communicate()
|
||||
|
||||
if p.returncode:
|
||||
return {
|
||||
'flags': default_flags,
|
||||
'do_cache': False,
|
||||
}
|
||||
return FlagsForFileDefault()
|
||||
|
||||
flags = stdout.split(' ')
|
||||
flags_relative = MakeRelativePathsInFlagsAbsolute(flags, os.path.join(DirectoryOfThisScript(), working_directory))
|
||||
@@ -113,11 +114,49 @@ def FlagsForFileLinux(filename):
|
||||
}
|
||||
|
||||
|
||||
def FlagsForFileDarwin(filename):
|
||||
working_directory = os.path.join('build', 'osx')
|
||||
|
||||
if not os.path.exists(os.path.join(DirectoryOfThisScript(), working_directory)):
|
||||
return FlagsForFileDefault()
|
||||
|
||||
relative_source_path = filename.replace(DirectoryOfThisScript() + '/', '')
|
||||
relative_obj_path = os.path.splitext(relative_source_path)[0] + '.o'
|
||||
|
||||
make_cmd = 'make -pn |grep "%s :=" |grep "NDEBUG" |tail -n 1 | cut -d\' \' -f4-' % relative_obj_path
|
||||
|
||||
p = subprocess.Popen([make_cmd], shell=True, stdout=subprocess.PIPE)
|
||||
stdout, stderr = p.communicate()
|
||||
|
||||
if p.returncode:
|
||||
return FlagsForFileDefault()
|
||||
|
||||
flags = stdout.split(' ')
|
||||
flags_relative = MakeRelativePathsInFlagsAbsolute(flags, os.path.join(DirectoryOfThisScript(), working_directory))
|
||||
flags_final = [flag for flag in flags_relative if flag.startswith("-")]
|
||||
|
||||
# Append OSX sysroot SDK path
|
||||
xcrun_cmd = 'xcrun --show-sdk-path'
|
||||
|
||||
p = subprocess.Popen([xcrun_cmd], shell=True, stdout=subprocess.PIPE)
|
||||
stdout, stderr = p.communicate()
|
||||
|
||||
if p.returncode:
|
||||
return FlagsForFileDefault()
|
||||
|
||||
flags_final.append('-isysroot ' + stdout)
|
||||
|
||||
return {
|
||||
'flags': flags_final,
|
||||
'do_cache': True,
|
||||
}
|
||||
|
||||
|
||||
def FlagsForFile(filename, **kwargs):
|
||||
if sys.platform.startswith('linux'):
|
||||
return FlagsForFileLinux(filename)
|
||||
|
||||
return {
|
||||
'flags': default_flags,
|
||||
'do_cache': False,
|
||||
}
|
||||
if sys.platform.startswith('darwin'):
|
||||
return FlagsForFileDarwin(filename)
|
||||
|
||||
return FlagsForFileDefault()
|
||||
|
||||
43
CHANGELOG.md
@@ -1,5 +1,48 @@
|
||||
# Changelog
|
||||
|
||||
## iOS 2.0.0
|
||||
|
||||
Repackaging 2.0.0-pre.1 as it contained no issues.
|
||||
|
||||
## iOS 2.0.0-pre.1
|
||||
|
||||
Repackaging 0.5.1 as the Mapbox iOS SDK 2.0.0 series.
|
||||
|
||||
## 0.5.1
|
||||
|
||||
### iOS
|
||||
|
||||
- Added support for CocoaPods 0.38.0. ([#1876](https://github.com/mapbox/mapbox-gl-native/pull/1876))
|
||||
|
||||
## 0.5.0
|
||||
|
||||
### Core
|
||||
|
||||
- Support for runtime marker imagery. ([#941](https://github.com/mapbox/mapbox-gl-native/pull/941))
|
||||
- Added `Map::fitBounds()` for region-based viewport setting. ([#1092](https://github.com/mapbox/mapbox-gl-native/issues/1092))
|
||||
- Added a raster satellite bundled style and improved raster rendering. ([#963](https://github.com/mapbox/mapbox-gl-native/issues/963))
|
||||
- Improved round line joins for semi-transparent lines. ([#1839](https://github.com/mapbox/mapbox-gl-native/pull/1839))
|
||||
- Improved map render lifecycle notifications. ([#1026](https://github.com/mapbox/mapbox-gl-native/issues/1026))
|
||||
- Fixed a bug that caused annotations not to show at zoom level zero. ([#1279](https://github.com/mapbox/mapbox-gl-native/issues/1279))
|
||||
- Fixed a bug with the ordering of shape layers. ([#1866](https://github.com/mapbox/mapbox-gl-native/pull/1866))
|
||||
- Other bug fixes and performance improvements.
|
||||
|
||||
### iOS
|
||||
|
||||
- **Breaking:** Headers now make use of lightweight generics, eliminating many unnecessary casts when working with annotations in Swift 2.0 in Xcode 7. ([#1711](https://github.com/mapbox/mapbox-gl-native/pull/1711))
|
||||
- **Breaking:** `-mapView:symbolNameForAnnotation:` has been removed from the `MGLMapViewDelegate` protocol. Implement `-mapView:imageForAnnotation:` instead, which accepts images at runtime. ([#941](https://github.com/mapbox/mapbox-gl-native/pull/941))
|
||||
- **Breaking:** `MGLMapView.direction` is now expressed in terms of degrees clockwise from true north, as indicated in the documentation, rather than counterclockwise. ([#1789](https://github.com/mapbox/mapbox-gl-native/pull/1789))
|
||||
- A Satellite style showing Mapbox Satellite imagery is now bundled with Mapbox GL. ([#1845](https://github.com/mapbox/mapbox-gl-native/pull/1845))
|
||||
- Improved `UIView` tracking to the map. ([#1813](https://github.com/mapbox/mapbox-gl-native/pull/1813))
|
||||
- Delegate method `-[MGLMapViewDelegate mapView:didFailToLocateUserWithError:]` now works. ([#1608](https://github.com/mapbox/mapbox-gl-native/pull/1608))
|
||||
- It is now possible to fit the map’s viewport to a coordinate bounding box via `-[MGLMapView setVisibleCoordinateBounds:animated:]` or to a specific set of coordinates via `-[MGLMapView setVisibleCoordinates:count:edgePadding:animated:]`. ([#1783](https://github.com/mapbox/mapbox-gl-native/pull/1783), [#1795](https://github.com/mapbox/mapbox-gl-native/pull/1795))
|
||||
- The logo and ℹ️ no longer disappear or get distorted after embedding MGLMapView in a different view, and you can now access these subviews directly via properties on MGLMapView. ([#1779](https://github.com/mapbox/mapbox-gl-native/pull/1779), [#1815](https://github.com/mapbox/mapbox-gl-native/pull/1815))
|
||||
- Raster tiles now look sharper midway between two zoom levels. ([#1843](https://github.com/mapbox/mapbox-gl-native/pull/1843))
|
||||
- Resetting the map rotation to north no longer also resets the user location tracking mode. ([#1809](https://github.com/mapbox/mapbox-gl-native/pull/1809))
|
||||
- `-[MGLMapView convertPoint:toCoordinateFromView:]` now returns accurate coordinates on iPhone 6. ([#1827](https://github.com/mapbox/mapbox-gl-native/pull/1827))
|
||||
- Fixed an issue in which `-[MGLMapView direction]` would sometimes return 360 instead of 0. ([#1829](https://github.com/mapbox/mapbox-gl-native/pull/1829))
|
||||
- Build against iOS 8.4. ([#1868](https://github.com/mapbox/mapbox-gl-native/pull/1868))
|
||||
|
||||
## 0.4.0
|
||||
|
||||
### Core
|
||||
|
||||
11
CONTRIBUTING.md
Normal file
@@ -0,0 +1,11 @@
|
||||
# Contributing
|
||||
|
||||
If you have a usage question for a product built on Mapbox GL (such as Mapbox Mobile toolkits like our SDKs), please visit https://www.mapbox.com/help/.
|
||||
|
||||
If you want to contribute code:
|
||||
|
||||
1. Please familiarize yourself with the [install process](INSTALL.md).
|
||||
|
||||
1. Ensure that the [existing issues](https://github.com/mapbox/mapbox-gl-native/issues?utf8=✓&q=) don't already cover your question or contribution.
|
||||
|
||||
1. Pull requests gladly accepted.
|
||||
351
INSTALL.md
Normal file
@@ -0,0 +1,351 @@
|
||||
# Install
|
||||
|
||||
This document describes the process for setting up Mapbox GL for development _on the framework itself_.
|
||||
|
||||
# Depends
|
||||
|
||||
- Modern C++ compiler that supports `-std=c++14` (clang++ 3.5 or later or g++-4.9 or later)
|
||||
- [Boost headers](http://boost.org/)
|
||||
- [`zlib`](http://www.zlib.net/)
|
||||
- [`libpng`](http://www.libpng.org/pub/png/libpng.html)
|
||||
- [`libuv 0.10+`](https://github.com/joyent/libuv)
|
||||
- [`glfw 3.1+`](http://www.glfw.org/)
|
||||
- [`libcurl`](http://curl.haxx.se/libcurl/) (depends on OpenSSL; Linux only)
|
||||
- Apple Command Line Tools (for build on OS X; available at [Apple Developer](https://developer.apple.com/downloads))
|
||||
- `pkg-config` (for build only)
|
||||
- [Homebrew](http://brew.sh) (for building on OS X)
|
||||
- [xcpretty](https://github.com/supermarin/xcpretty) (for building on OS X)
|
||||
- [Cask](http://caskroom.io/) (for building Android on OS X)
|
||||
- Python 2.x (for build only)
|
||||
|
||||
# Build instructions
|
||||
|
||||
We try to link to as many system-provided libraries as possible. When these are unavailable or too outdated, we run a thin build-script layer called [Mason](https://github.com/mapbox/mason) to automate builds, and load precompiled binary packages when possible.
|
||||
|
||||
Be sure to pull down all submodules first:
|
||||
|
||||
git submodule init
|
||||
git submodule update
|
||||
|
||||
## OS X
|
||||
|
||||
This process gives you either a native OS X windowed app or a Linux desktop app with a map view for development purposes, built on an OS X host system.
|
||||
|
||||
### Build
|
||||
|
||||
ImageMagick is required for tests. It's recommended to install it with [Homebrew](http://brew.sh/) via `brew install imagemagick`.
|
||||
|
||||
To create projects, you can run:
|
||||
|
||||
- `make xproj`: Creates an Xcode project with OS X-specific handlers for HTTP downloads and settings storage. It uses [GLFW](http://www.glfw.org) for window handling.
|
||||
- `make lproj`: Creates an Xcode project with platform-independent handlers for downloads and settings storage. This is what is also being built on Linux.
|
||||
- `make osx run-osx`: Builds and runs the OS X application on the command line with `xcodebuild`.
|
||||
- `make linux run-linux`: Builds and runs the Linux application with `make`.
|
||||
|
||||
Note that you can't have more than one project in Xcode open at a time since the static library project is shared across the OS X, Linux and iOS project.
|
||||
|
||||
### Test
|
||||
|
||||
- `make test-*` Builds and runs all tests. You can specify individual tests by replacing * with their name.
|
||||
|
||||
### Usage
|
||||
|
||||
- Press `S` to cycle through bundled styles
|
||||
- Press `X` to reset the transform
|
||||
- Press `N` to reset north
|
||||
- Press `Tab` to toggle debug information
|
||||
- Press `C` to toggle symbol collision debug boxes
|
||||
- Press `Esc` to quit
|
||||
- Press `1` through `6` to add increasing numbers of point annotations for testing
|
||||
|
||||
### Target
|
||||
|
||||
OS X 10.9+
|
||||
|
||||
|
||||
## iOS (Test App)
|
||||
|
||||
This process gives you a native iOS app for simulator or device which compiles the source to GL within it for fastest turnaround time during development. Normal, production use of the library is via a precompiled binary linked into the app target.
|
||||
|
||||
Developing for iOS implies an OS X host system.
|
||||
|
||||
### Build
|
||||
|
||||
If you want to build from source and/or contribute to development of the project, run `make iproj`, which will create and open an Xcode project which can build the entire library from source as well as an Objective-C test app. If you don't have an Apple Developer account, change the destination from "My Mac" to a simulator such as "iPhone 6" before you run and build the app.
|
||||
|
||||
### Test
|
||||
|
||||
You can run `make itest` to run the included integration tests. Requires `gem install xcpretty`. If you want to run the tests in Xcode instead, first `make ipackage` to create a local static library version, then open `test/ios/ios-tests.xcodeproj`, and lastly `Command + U` on the `Mapbox GL Tests` application target.
|
||||
|
||||
### Usage
|
||||
|
||||
- Pan to move
|
||||
- Pinch to zoom
|
||||
- Use two fingers to rotate
|
||||
- Double-tap to zoom in one level
|
||||
- Two-finger single-tap to zoom out one level
|
||||
- Double-tap, long-pressing the second, then pan up and down to "quick zoom" (iPhone only, meant for one-handed use)
|
||||
- Use the debug menu to add test annotations, reset position, and toggle debug info.
|
||||
|
||||
## iOS (Your App)
|
||||
|
||||
**If you want a production version of this project, use [Mapbox Mobile](http://mapbox.com/mobile).**
|
||||
|
||||
This section is for people contributing to Mapbox GL directly in the context of their own app.
|
||||
|
||||
### Build
|
||||
|
||||
1. Install [appledoc](http://appledoc.gentlebytes.com/appledoc/) 2.2v963 for API docs generation (only this exact version works right now ([#2117](https://github.com/mapbox/mapbox-gl-native/issues/2117)).
|
||||
|
||||
```
|
||||
curl -L -o appledoc.zip https://github.com/tomaz/appledoc/releases/download/v2.2-963/appledoc.zip
|
||||
unzip appledoc.zip
|
||||
cp appledoc /usr/local/bin
|
||||
cp -Rf Templates/ ~/.appledoc
|
||||
```
|
||||
|
||||
1. Run `make ipackage`. The packaging script will produce the statically-linked `libMapbox.a`, `Mapbox.bundle` for resources, a `Headers` folder, and a `Docs` folder with HTML API documentation.
|
||||
|
||||
### Test
|
||||
|
||||
In the context of your own app, you can now either:
|
||||
|
||||
#### CocoaPods
|
||||
|
||||
Currently, until [#1437](https://github.com/mapbox/mapbox-gl-native/issues/1437) is completed, to install a _development version_ of Mapbox GL using CocoaPods you will need to build it from source manually per above.
|
||||
|
||||
1. Zip up the build product.
|
||||
|
||||
cd build/ios/pkg/static
|
||||
ZIP=mapbox-ios-sdk.zip
|
||||
rm -f ../${ZIP}
|
||||
zip -r ../${ZIP} *
|
||||
|
||||
1. Modify a custom `Mapbox-iOS-SDK.podspec` to download this zip file.
|
||||
|
||||
{...}
|
||||
|
||||
m.source = {
|
||||
:http => "http://{...}/mapbox-ios-sdk.zip",
|
||||
:flatten => true
|
||||
}
|
||||
|
||||
{...}
|
||||
|
||||
1. Update your app's `Podfile` to point to the `Mapbox-iOS-SDK.podspec`.
|
||||
|
||||
pod 'Mapbox-iOS-SDK', :podspec => 'http://{...}/Mapbox-iOS-SDK.podspec'
|
||||
|
||||
1. Run `pod update` to grab the newly-built library.
|
||||
|
||||
#### Binary
|
||||
|
||||
1. Built from source manually per above.
|
||||
|
||||
1. Copy the contents of `build/ios/pkg/static` into your project. It should happen automatically, but ensure that:
|
||||
|
||||
- `Headers` is in your *Header Search Paths* (`HEADER_SEARCH_PATHS`) build setting.
|
||||
- `Mapbox.bundle` is in your target's *Copy Bundle Resources* build phase.
|
||||
- `libMapbox.a` is in your target's *Link Binary With Libraries* build phase.
|
||||
|
||||
1. Add the following Cocoa framework dependencies to your target's *Link Binary With Libraries* build phase:
|
||||
|
||||
- `CoreTelephony.framework`
|
||||
- `GLKit.framework`
|
||||
- `ImageIO.framework`
|
||||
- `MobileCoreServices.framework`
|
||||
- `QuartzCore.framework`
|
||||
- `SystemConfiguration.framework`
|
||||
- `libc++.dylib`
|
||||
- `libsqlite3.dylib`
|
||||
- `libz.dylib`
|
||||
|
||||
1. Add `-ObjC` to your target's "Other Linker Flags" build setting (`OTHER_LDFLAGS`).
|
||||
|
||||
### Target
|
||||
|
||||
Devices: iPhone 4S and above (5, 5c, 5s, 6, 6 Plus), iPad 2 and above (3, 4, Mini, Air, Mini 2, Air 2), iPod touch 5th gen and above
|
||||
|
||||
iOS: 7.0+
|
||||
|
||||
|
||||
## Linux
|
||||
|
||||
We are using Ubuntu for development. While the software should work on other distributions as well, we are not providing explicit build instructions here.
|
||||
|
||||
This process gives you a Linux desktop app built on a Linux host system.
|
||||
|
||||
### Build
|
||||
|
||||
Install GCC 4.9+ if you are running Ubuntu 14.04 or older. Alternatively, you can also use [Clang 3.5+](http://llvm.org/apt/).
|
||||
|
||||
sudo add-apt-repository --yes ppa:ubuntu-toolchain-r/test
|
||||
sudo apt-get update
|
||||
sudo apt-get install gcc-4.9 g++-4.9
|
||||
export CXX=g++-4.9
|
||||
|
||||
Ensure you have git and other build essentials:
|
||||
|
||||
sudo apt-get install curl git build-essential zlib1g-dev automake \
|
||||
libtool xutils-dev make cmake pkg-config python-pip \
|
||||
libcurl4-openssl-dev libpng-dev libsqlite3-dev \
|
||||
libllvm3.4
|
||||
|
||||
Install glfw3 dependencies:
|
||||
|
||||
sudo apt-get install libxi-dev libglu1-mesa-dev x11proto-randr-dev \
|
||||
x11proto-xext-dev libxrandr-dev \
|
||||
x11proto-xf86vidmode-dev libxxf86vm-dev \
|
||||
libxcursor-dev libxinerama-dev
|
||||
|
||||
Then, you can then proceed to build the library:
|
||||
|
||||
git submodule update --init
|
||||
make linux
|
||||
|
||||
Set an access token as described below, and then run:
|
||||
|
||||
make run-linux
|
||||
|
||||
### Test
|
||||
|
||||
- `make test-*` Builds and runs all tests. You can specify individual tests by replacing * with their name.
|
||||
|
||||
### Usage
|
||||
|
||||
- Press `S` to cycle through bundled styles
|
||||
- Press `X` to reset the transform
|
||||
- Press `N` to reset north
|
||||
- Press `Tab` to toggle debug information
|
||||
- Press `C` to toggle symbol collision debug boxes
|
||||
- Press `Esc` to quit
|
||||
- Press `1` through `6` to add increasing numbers of point annotations for testing
|
||||
|
||||
### Target
|
||||
|
||||
Ubuntu
|
||||
|
||||
|
||||
## Android
|
||||
|
||||
### Build (Linux Host)
|
||||
|
||||
Install a few build dependencies:
|
||||
|
||||
apt-get install -y make git build-essential automake \
|
||||
libtool make cmake pkg-config lib32stdc++6 lib32z1
|
||||
|
||||
Install Oracle JDK 7 (requires license agreement) from http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html
|
||||
|
||||
export JAVA_HOME="/dir/to/jdk1.7.0_71"
|
||||
|
||||
Install the [Android NDK Revision 10e](https://developer.android.com/tools/sdk/ndk/index.html).
|
||||
|
||||
export ANDROID_NDK_PATH="/dir/to/android-ndk-r10e"
|
||||
|
||||
Install the Android SDK. We recommend doing this by way of [Android Studio](https://developer.android.com/sdk/installing/studio.html).
|
||||
|
||||
export ANDROID_HOME="/dir/to/android-sdk-linux"
|
||||
|
||||
Run:
|
||||
|
||||
make android
|
||||
|
||||
You can then open `android/java` in Android Studio via "Import Non-Android Studio Project".
|
||||
|
||||
### Build (OS X Host)
|
||||
|
||||
Install Oracle JDK 7+:
|
||||
|
||||
brew cask install java
|
||||
|
||||
Install the [Android NDK Revision 10e](https://developer.android.com/tools/sdk/ndk/index.html) for 64-bit OS X:
|
||||
|
||||
brew install android-ndk
|
||||
|
||||
This will also install the dependency `android-sdk`.
|
||||
|
||||
Install [Android Studio](https://developer.android.com/sdk/installing/studio.html):
|
||||
|
||||
brew cask install android-studio
|
||||
android
|
||||
|
||||
By default, the SDK will be installed to `/usr/local/opt/android-sdk`. If you open Android Studio at this point, you may get an error message telling you that it can't find a JVM, it's because you installed a custom Java VM from Oracle. Follow [these instructions](http://tools.android.com/recent/androidstudio1rc3_releasecandidate3released) to start Android Studio. You'll wind up setting these environment variables in your .bash_profile or similar:
|
||||
|
||||
echo "export ANDROID_HOME=`brew --prefix android-sdk`" >> .bash_profile
|
||||
echo "export ANDROID_NDK_PATH=`brew --cellar android-ndk`/r10e" >> .bash_profile
|
||||
# Replace <path> with something like /Library/Java/JavaVirtualMachines/jdk1.8.0_31.jdk/Contents/Home
|
||||
echo "export JAVA_HOME=<path>" >> .bash_profile
|
||||
echo "export STUDIO_JDK=$JAVA_HOME" >> .bash_profile
|
||||
|
||||
Run:
|
||||
|
||||
make android
|
||||
open -a Android\ Studio
|
||||
|
||||
You can then open `android/java` in Android Studio via "import project (Eclipse ADT, Gradle, etc.)".
|
||||
|
||||
### Setting up Android emulator
|
||||
|
||||
If you want to run the test app in the emulator, we recommend the x86 build because it will run a lot faster.
|
||||
|
||||
First ensure you have an `MAPBOX_ACCESS_TOKEN` environment variable set, as described below. Then, create an x86 build:
|
||||
|
||||
ANDROID_ABI=x86 make android
|
||||
|
||||
In Android Studio, create an x86 AVD (Android Virtual Device):
|
||||
|
||||
- Open AVD Manager via the Tools menu -> Android -> AVD Manager
|
||||
- Click "Create Virtual Device" at the bottom on AVD Manager window
|
||||
- Select one of the device profiles, for example the Nexus 4
|
||||
- Click "Next"
|
||||
- Select a Lollipop or Kitkat release with ABI of x86. If the line is greyed out click Download to download the OS files.
|
||||
- Click "Next"
|
||||
- Under "Emulated Performance" check "Host GPU" and uncheck "Store a snapshot for faster startup"
|
||||
- Click "Finish"
|
||||
- Close the AVD Manager
|
||||
|
||||
Now when you run or debug the Android project you will see a window "Choose Device". Select your new AVD from drop down under "Launch emulator". If you select "Use same device for future launches" Android Studio will remember the selection and not ask again.
|
||||
|
||||
### Running on a hardware device
|
||||
|
||||
First read the [Google documentation](http://developer.android.com/tools/device.html) to set up your device and your OS to connect to the device.
|
||||
|
||||
When you plug your device in and then run or debug the Android project you will see a window "Choose Device". Choose your device from the "Choose a running device" list.
|
||||
|
||||
If your device does not show up, you have not set it up properly. Double check the [Google documentation](http://developer.android.com/tools/device.html).
|
||||
|
||||
### Distribution
|
||||
|
||||
Use the `Makefile` target `make apackage` in order to build JNI libraries for all supported ABI's for eventual distribution of the whole package.
|
||||
|
||||
### Target
|
||||
|
||||
Devices running Android 4.0+ (API level 14+).
|
||||
|
||||
|
||||
# Troubleshooting
|
||||
|
||||
To trigger a complete rebuild, run `make clean` and then start over generating the Xcode projects or `Makefile` as described above.
|
||||
|
||||
If you are having trouble getting the dependencies right, you can blow away the `mason_packages` directory, or run `make distclean`. This means the `Makefile` and configure script will automatically install the dependencies again on the next try.
|
||||
|
||||
On OS X, you can also try clearing the Xcode cache with `make clear_xcode_cache`.
|
||||
|
||||
# Mapbox API access tokens
|
||||
|
||||
The demo applications use Mapbox vector tiles, which **require a Mapbox account and API access token**. Obtain an access token on the [Mapbox account page](https://www.mapbox.com/account/apps/).
|
||||
|
||||
For iOS and OS X use of the demo apps in Xcode, setup the access token by editing the scheme for the application target, then adding an environment variable with the name `MAPBOX_ACCESS_TOKEN`.
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
For Linux, set the environment variable `MAPBOX_ACCESS_TOKEN` to your token.
|
||||
|
||||
For Android, gradle will take the value of `MAPBOX_ACCESS_TOKEN` and save it to `android/java/MapboxGLAndroidSDKTestApp/src/main/res/raw/token.txt` where the app will read it from.
|
||||
|
||||
# Style
|
||||
|
||||
Default styles in the JSON-based [styling format](https://github.com/mapbox/mapbox-gl-style-spec) are included at `./styles` as a submodule. See the [styles project](https://github.com/mapbox/mapbox-gl-styles) to report problems or to contribute to these styles.
|
||||
852
LICENSE.md
@@ -1,15 +1,15 @@
|
||||
mapbox-gl-native copyright (c) 2014, Mapbox.
|
||||
mapbox-gl-native copyright (c) 2014, Mapbox.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
@@ -25,6 +25,525 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
===========================================================================
|
||||
|
||||
Mapbox GL uses portions of Android Gesture Detectors Framework.
|
||||
|
||||
Copyright (c) 2012, Almer Thie
|
||||
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
===========================================================================
|
||||
|
||||
Mapbox GL uses portions of Android Support Library.
|
||||
|
||||
Copyright (c) 2005-2013, The Android Open Source Project
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
===========================================================================
|
||||
|
||||
Mapbox GL uses portions of Boost.
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
|
||||
http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
===========================================================================
|
||||
|
||||
Mapbox GL uses portions of Clipper.
|
||||
|
||||
Author : Angus Johnson
|
||||
Version : 6.1.3a
|
||||
Date : 22 January 2014
|
||||
Website : http://www.angusj.com
|
||||
Copyright : Angus Johnson 2010-2014
|
||||
|
||||
License:
|
||||
Use, modification & distribution is subject to Boost Software License Ver 1.
|
||||
http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
Attributions:
|
||||
The code in this library is an extension of Bala Vatti's clipping algorithm:
|
||||
"A generic solution to polygon clipping"
|
||||
Communications of the ACM, Vol 35, Issue 7 (July 1992) pp 56-63.
|
||||
http://portal.acm.org/citation.cfm?id=129906
|
||||
|
||||
Computer graphics and geometric modeling: implementation and algorithms
|
||||
By Max K. Agoston
|
||||
Springer; 1 edition (January 4, 2005)
|
||||
http://books.google.com/books?q=vatti+clipping+agoston
|
||||
|
||||
See also:
|
||||
"Polygon Offsetting by Computing Winding Numbers"
|
||||
Paper no. DETC2005-85513 pp. 565-575
|
||||
ASME 2005 International Design Engineering Technical Conferences
|
||||
and Computers and Information in Engineering Conference (IDETC/CIE2005)
|
||||
September 24-28, 2005 , Long Beach, California, USA
|
||||
http://www.me.berkeley.edu/~mcmains/pubs/DAC05OffsetPolygon.pdf
|
||||
|
||||
===========================================================================
|
||||
|
||||
Mapbox GL uses portions of CSS Color Parser.
|
||||
|
||||
(c) Dean McNamee <dean@gmail.com>, 2012.
|
||||
C++ port by Konstantin Käfer <mail@kkaefer.com>, 2014.
|
||||
|
||||
https://github.com/deanm/css-color-parser-js
|
||||
https://github.com/kkaefer/css-color-parser-cpp
|
||||
|
||||
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.
|
||||
|
||||
===========================================================================
|
||||
|
||||
Mapbox GL uses portions of GLFW.
|
||||
|
||||
Copyright (c) 2002-2006 Marcus Geelnard
|
||||
Copyright (c) 2006-2010 Camilla Berglund <elmindreda@elmindreda.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would
|
||||
be appreciated but is not required.
|
||||
|
||||
2. Altered source versions must be plainly marked as such, and must not
|
||||
be misrepresented as being the original software.
|
||||
|
||||
3. This notice may not be removed or altered from any source
|
||||
distribution.
|
||||
|
||||
===========================================================================
|
||||
|
||||
Mapbox GL uses portions of libc++.
|
||||
|
||||
The libc++ library is dual licensed under both the University of Illinois
|
||||
"BSD-Like" license and the MIT license. As a user of this code you may choose
|
||||
to use it under either license. As a contributor, you agree to allow your code
|
||||
to be used under both.
|
||||
|
||||
Full text of the relevant licenses is included below.
|
||||
|
||||
====
|
||||
|
||||
University of Illinois/NCSA
|
||||
Open Source License
|
||||
|
||||
Copyright (c) 2009-2015 by the contributors listed in CREDITS.TXT
|
||||
|
||||
All rights reserved.
|
||||
|
||||
Developed by:
|
||||
|
||||
LLVM Team
|
||||
|
||||
University of Illinois at Urbana-Champaign
|
||||
|
||||
http://llvm.org
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal with
|
||||
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:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimers.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimers in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
* Neither the names of the LLVM Team, University of Illinois at
|
||||
Urbana-Champaign, nor the names of its contributors may be used to
|
||||
endorse or promote products derived from this Software without specific
|
||||
prior written permission.
|
||||
|
||||
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
|
||||
CONTRIBUTORS 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 WITH THE
|
||||
SOFTWARE.
|
||||
|
||||
====
|
||||
|
||||
Copyright (c) 2009-2014 by the contributors listed in CREDITS.TXT
|
||||
|
||||
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.
|
||||
|
||||
===========================================================================
|
||||
|
||||
Mapbox GL uses portions of libcurl.
|
||||
|
||||
COPYRIGHT AND PERMISSION NOTICE
|
||||
|
||||
Copyright (c) 1996 - 2015, Daniel Stenberg, <daniel@haxx.se>.
|
||||
|
||||
All rights reserved.
|
||||
|
||||
Permission to use, copy, modify, and distribute this software for any purpose
|
||||
with or without fee is hereby granted, provided that the above copyright
|
||||
notice and this permission notice appear in all copies.
|
||||
|
||||
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 OF THIRD PARTY RIGHTS. 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.
|
||||
|
||||
Except as contained in this notice, the name of a copyright holder shall not
|
||||
be used in advertising or otherwise to promote the sale, use or other dealings
|
||||
in this Software without prior written authorization of the copyright holder.
|
||||
|
||||
===========================================================================
|
||||
|
||||
Mapbox GL uses portions of libjpeg.
|
||||
|
||||
The authors make NO WARRANTY or representation, either express or implied,
|
||||
with respect to this software, its quality, accuracy, merchantability, or
|
||||
fitness for a particular purpose. This software is provided "AS IS", and you,
|
||||
its user, assume the entire risk as to its quality and accuracy.
|
||||
|
||||
This software is copyright (C) 1991-2014, Thomas G. Lane, Guido Vollbeding.
|
||||
All Rights Reserved except as specified below.
|
||||
|
||||
Permission is hereby granted to use, copy, modify, and distribute this
|
||||
software (or portions thereof) for any purpose, without fee, subject to these
|
||||
conditions:
|
||||
(1) If any part of the source code for this software is distributed, then this
|
||||
README file must be included, with this copyright and no-warranty notice
|
||||
unaltered; and any additions, deletions, or changes to the original files
|
||||
must be clearly indicated in accompanying documentation.
|
||||
(2) If only executable code is distributed, then the accompanying
|
||||
documentation must state that "this software is based in part on the work of
|
||||
the Independent JPEG Group".
|
||||
(3) Permission for use of this software is granted only if the user accepts
|
||||
full responsibility for any undesirable consequences; the authors accept
|
||||
NO LIABILITY for damages of any kind.
|
||||
|
||||
These conditions apply to any software derived from or based on the IJG code,
|
||||
not just to the unmodified library. If you use our work, you ought to
|
||||
acknowledge us.
|
||||
|
||||
Permission is NOT granted for the use of any IJG author's name or company name
|
||||
in advertising or publicity relating to this software or products derived from
|
||||
it. This software may be referred to only as "the Independent JPEG Group's
|
||||
software".
|
||||
|
||||
We specifically permit and encourage the use of this software as the basis of
|
||||
commercial products, provided that all warranty or liability claims are
|
||||
assumed by the product vendor.
|
||||
|
||||
|
||||
The Unix configuration script "configure" was produced with GNU Autoconf.
|
||||
It is copyright by the Free Software Foundation but is freely distributable.
|
||||
The same holds for its supporting scripts (config.guess, config.sub,
|
||||
ltmain.sh). Another support script, install-sh, is copyright by X Consortium
|
||||
but is also freely distributable.
|
||||
|
||||
The IJG distribution formerly included code to read and write GIF files.
|
||||
To avoid entanglement with the Unisys LZW patent (now expired), GIF reading
|
||||
support has been removed altogether, and the GIF writer has been simplified
|
||||
to produce "uncompressed GIFs". This technique does not use the LZW
|
||||
algorithm; the resulting GIF files are larger than usual, but are readable
|
||||
by all standard GIF decoders.
|
||||
|
||||
We are required to state that
|
||||
"The Graphics Interchange Format(c) is the Copyright property of
|
||||
CompuServe Incorporated. GIF(sm) is a Service Mark property of
|
||||
CompuServe Incorporated."
|
||||
|
||||
===========================================================================
|
||||
|
||||
Mapbox GL uses portions of libpng.
|
||||
|
||||
This copy of the libpng notices is provided for your convenience. In case of
|
||||
any discrepancy between this copy and the notices in the file png.h that is
|
||||
included in the libpng distribution, the latter shall prevail.
|
||||
|
||||
COPYRIGHT NOTICE, DISCLAIMER, and LICENSE:
|
||||
|
||||
If you modify libpng you may insert additional notices immediately following
|
||||
this sentence.
|
||||
|
||||
This code is released under the libpng license.
|
||||
|
||||
libpng versions 1.0.7, July 1, 2000, through 1.6.18, July 23, 2015, are
|
||||
Copyright (c) 2000-2002, 2004, 2006-2015 Glenn Randers-Pehrson, and are
|
||||
distributed according to the same disclaimer and license as libpng-1.0.6
|
||||
with the following individuals added to the list of Contributing Authors:
|
||||
|
||||
Simon-Pierre Cadieux
|
||||
Eric S. Raymond
|
||||
Mans Rullgard
|
||||
Cosmin Truta
|
||||
Gilles Vollant
|
||||
James Yu
|
||||
|
||||
and with the following additions to the disclaimer:
|
||||
|
||||
There is no warranty against interference with your enjoyment of the
|
||||
library or against infringement. There is no warranty that our
|
||||
efforts or the library will fulfill any of your particular purposes
|
||||
or needs. This library is provided with all faults, and the entire
|
||||
risk of satisfactory quality, performance, accuracy, and effort is with
|
||||
the user.
|
||||
|
||||
libpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are
|
||||
Copyright (c) 1998-2000 Glenn Randers-Pehrson, and are distributed according
|
||||
to the same disclaimer and license as libpng-0.96, with the following
|
||||
individuals added to the list of Contributing Authors:
|
||||
|
||||
Tom Lane
|
||||
Glenn Randers-Pehrson
|
||||
Willem van Schaik
|
||||
|
||||
libpng versions 0.89, June 1996, through 0.96, May 1997, are
|
||||
Copyright (c) 1996-1997 Andreas Dilger, and are
|
||||
distributed according to the same disclaimer and license as libpng-0.88,
|
||||
with the following individuals added to the list of Contributing Authors:
|
||||
|
||||
John Bowler
|
||||
Kevin Bracey
|
||||
Sam Bushell
|
||||
Magnus Holmgren
|
||||
Greg Roelofs
|
||||
Tom Tanner
|
||||
|
||||
libpng versions 0.5, May 1995, through 0.88, January 1996, are
|
||||
Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
|
||||
For the purposes of this copyright and license, "Contributing Authors"
|
||||
is defined as the following set of individuals:
|
||||
|
||||
Andreas Dilger
|
||||
Dave Martindale
|
||||
Guy Eric Schalnat
|
||||
Paul Schmidt
|
||||
Tim Wegner
|
||||
|
||||
The PNG Reference Library is supplied "AS IS". The Contributing Authors
|
||||
and Group 42, Inc. disclaim all warranties, expressed or implied,
|
||||
including, without limitation, the warranties of merchantability and of
|
||||
fitness for any purpose. The Contributing Authors and Group 42, Inc.
|
||||
assume no liability for direct, indirect, incidental, special, exemplary,
|
||||
or consequential damages, which may result from the use of the PNG
|
||||
Reference Library, even if advised of the possibility of such damage.
|
||||
|
||||
Permission is hereby granted to use, copy, modify, and distribute this
|
||||
source code, or portions hereof, for any purpose, without fee, subject
|
||||
to the following restrictions:
|
||||
|
||||
1. The origin of this source code must not be misrepresented.
|
||||
|
||||
2. Altered versions must be plainly marked as such and must not
|
||||
be misrepresented as being the original source.
|
||||
|
||||
3. This Copyright notice may not be removed or altered from any
|
||||
source or altered source distribution.
|
||||
|
||||
The Contributing Authors and Group 42, Inc. specifically permit, without
|
||||
fee, and encourage the use of this source code as a component to
|
||||
supporting the PNG file format in commercial products. If you use this
|
||||
source code in a product, acknowledgment is not required but would be
|
||||
appreciated.
|
||||
|
||||
===========================================================================
|
||||
|
||||
Mapbox GL uses portions of libtess2.
|
||||
|
||||
SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
|
||||
Copyright (C) [dates of first publication] Silicon Graphics, Inc.
|
||||
All Rights Reserved.
|
||||
|
||||
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 including the dates of first publication and either this
|
||||
permission notice or a reference to http://oss.sgi.com/projects/FreeB/ 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 SILICON GRAPHICS, INC.
|
||||
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.
|
||||
|
||||
Except as contained in this notice, the name of Silicon Graphics, Inc. shall not
|
||||
be used in advertising or otherwise to promote the sale, use or other dealings in
|
||||
this Software without prior written authorization from Silicon Graphics, Inc.
|
||||
|
||||
===========================================================================
|
||||
|
||||
Mapbox GL uses portions of libuv.
|
||||
|
||||
libuv is part of the Node project: http://nodejs.org/
|
||||
libuv may be distributed alone under Node's license:
|
||||
|
||||
====
|
||||
|
||||
Copyright Joyent, Inc. and other Node contributors. All rights reserved.
|
||||
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.
|
||||
|
||||
====
|
||||
|
||||
This license applies to all parts of libuv that are not externally
|
||||
maintained libraries.
|
||||
|
||||
The externally maintained libraries used by libuv are:
|
||||
|
||||
- tree.h (from FreeBSD), copyright Niels Provos. Two clause BSD license.
|
||||
|
||||
- inet_pton and inet_ntop implementations, contained in src/inet.c, are
|
||||
copyright the Internet Systems Consortium, Inc., and licensed under the ISC
|
||||
license.
|
||||
|
||||
- stdint-msvc2008.h (from msinttypes), copyright Alexander Chemeris. Three
|
||||
clause BSD license.
|
||||
|
||||
- pthread-fixes.h, pthread-fixes.c, copyright Google Inc. and Sony Mobile
|
||||
Communications AB. Three clause BSD license.
|
||||
|
||||
- android-ifaddrs.h, android-ifaddrs.c, copyright Berkeley Software Design
|
||||
Inc, Kenneth MacKay and Emergya (Cloud4all, FP7/2007-2013, grant agreement
|
||||
n° 289016). Three clause BSD license.
|
||||
|
||||
===========================================================================
|
||||
|
||||
Mapbox GL uses portions of libzip.
|
||||
|
||||
Copyright (C) 1999-2014 Dieter Baron and Thomas Klausner
|
||||
|
||||
The authors can be contacted at <libzip@nih.at>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
|
||||
3. The names of the authors may not be used to endorse or promote
|
||||
products derived from this software without specific prior
|
||||
written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
|
||||
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
===========================================================================
|
||||
|
||||
Mapbox GL uses portions of LOST.
|
||||
|
||||
Copyright (c) 2014 Mapzen
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
===========================================================================
|
||||
|
||||
Mapbox GL uses portions of the Mapbox iOS SDK, which was derived from the
|
||||
Route-Me open source project, including the Alpstein fork of it.
|
||||
|
||||
@@ -37,10 +556,10 @@ Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
@@ -53,3 +572,316 @@ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
===========================================================================
|
||||
|
||||
Mapbox GL uses portions of nunicode.
|
||||
|
||||
Copyright (c) 2013 Aleksey Tulinov <aleksey.tulinov@gmail.com>
|
||||
|
||||
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.
|
||||
|
||||
===========================================================================
|
||||
|
||||
Mapbox GL uses portions of OkHTTP.
|
||||
|
||||
Copyright 2014 Square, Inc.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
===========================================================================
|
||||
|
||||
Mapbox GL uses portions of OpenSSL.
|
||||
|
||||
LICENSE ISSUES
|
||||
==============
|
||||
|
||||
The OpenSSL toolkit stays under a dual license, i.e. both the conditions of
|
||||
the OpenSSL License and the original SSLeay license apply to the toolkit.
|
||||
See below for the actual license texts. Actually both licenses are BSD-style
|
||||
Open Source licenses. In case of any license issues related to OpenSSL
|
||||
please contact openssl-core@openssl.org.
|
||||
|
||||
OpenSSL License
|
||||
---------------
|
||||
|
||||
Copyright (c) 1998-2011 The OpenSSL Project. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
|
||||
3. All advertising materials mentioning features or use of this
|
||||
software must display the following acknowledgment:
|
||||
"This product includes software developed by the OpenSSL Project
|
||||
for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
|
||||
|
||||
4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
|
||||
endorse or promote products derived from this software without
|
||||
prior written permission. For written permission, please contact
|
||||
openssl-core@openssl.org.
|
||||
|
||||
5. Products derived from this software may not be called "OpenSSL"
|
||||
nor may "OpenSSL" appear in their names without prior written
|
||||
permission of the OpenSSL Project.
|
||||
|
||||
6. Redistributions of any form whatsoever must retain the following
|
||||
acknowledgment:
|
||||
"This product includes software developed by the OpenSSL Project
|
||||
for use in the OpenSSL Toolkit (http://www.openssl.org/)"
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
|
||||
EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
|
||||
ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
This product includes cryptographic software written by Eric Young
|
||||
(eay@cryptsoft.com). This product includes software written by Tim
|
||||
Hudson (tjh@cryptsoft.com).
|
||||
|
||||
Original SSLeay License
|
||||
-----------------------
|
||||
|
||||
Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
All rights reserved.
|
||||
|
||||
This package is an SSL implementation written
|
||||
by Eric Young (eay@cryptsoft.com).
|
||||
The implementation was written so as to conform with Netscapes SSL.
|
||||
|
||||
This library is free for commercial and non-commercial use as long as
|
||||
The following conditions are aheared to. The following conditions
|
||||
apply to all code found in this distribution, be it the RC4, RSA,
|
||||
lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
included with this distribution is covered by the same copyright terms
|
||||
except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
|
||||
Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
the code are not to be removed.
|
||||
If this package is used in a product, Eric Young should be given attribution
|
||||
as the author of the parts of the library used.
|
||||
This can be in the form of a textual message at program startup or
|
||||
in documentation (online or textual) provided with the package.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
3. All advertising materials mentioning features or use of this software
|
||||
must display the following acknowledgement:
|
||||
"This product includes cryptographic software written by
|
||||
Eric Young (eay@cryptsoft.com)"
|
||||
The word 'cryptographic' can be left out if the rouines from the library
|
||||
being used are not cryptographic related :-).
|
||||
4. If you include any Windows specific code (or a derivative thereof) from
|
||||
the apps directory (application code) you must include an acknowledgement:
|
||||
"This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGE.
|
||||
|
||||
The licence and distribution terms for any publically available version or
|
||||
derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||
copied and put under another distribution licence
|
||||
[including the GNU Public Licence.]
|
||||
|
||||
===========================================================================
|
||||
|
||||
Mapbox GL uses portions of RapidJSON.
|
||||
|
||||
Tencent is pleased to support the open source community by making RapidJSON available.
|
||||
|
||||
Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved.
|
||||
|
||||
If you have downloaded a copy of the RapidJSON binary from Tencent, please note that the RapidJSON binary is licensed under the MIT License.
|
||||
If you have downloaded a copy of the RapidJSON source code from Tencent, please note that RapidJSON source code is licensed under the MIT License, except for the third-party components listed below which are subject to different license terms. Your integration of RapidJSON into your own projects may require compliance with the MIT License, as well as the other licenses applicable to the third-party components included within RapidJSON. To avoid the problematic JSON license in your own projects, it's sufficient to exclude the bin/jsonchecker/ directory, as it's the only code under the JSON license.
|
||||
A copy of the MIT License is included in this file.
|
||||
|
||||
Other dependencies and licenses:
|
||||
|
||||
Open Source Software Licensed Under the BSD License:
|
||||
--------------------------------------------------------------------
|
||||
|
||||
The msinttypes r29
|
||||
Copyright (c) 2006-2013 Alexander Chemeris
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
Open Source Software Licensed Under the JSON License:
|
||||
--------------------------------------------------------------------
|
||||
|
||||
json.org
|
||||
Copyright (c) 2002 JSON.org
|
||||
All Rights Reserved.
|
||||
|
||||
JSON_checker
|
||||
Copyright (c) 2002 JSON.org
|
||||
All Rights Reserved.
|
||||
|
||||
Terms of the JSON License:
|
||||
---------------------------------------------------
|
||||
|
||||
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 shall be used for Good, not Evil.
|
||||
|
||||
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.
|
||||
|
||||
Terms of the MIT License:
|
||||
--------------------------------------------------------------------
|
||||
|
||||
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.
|
||||
|
||||
===========================================================================
|
||||
|
||||
Mapbox GL uses portions of Reachability.
|
||||
|
||||
Copyright (c) 2011, Tony Million.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
===========================================================================
|
||||
|
||||
Mapbox GL uses portions of SQLite.
|
||||
|
||||
2001 September 15
|
||||
|
||||
The author disclaims copyright to this source code. In place of
|
||||
a legal notice, here is a blessing:
|
||||
|
||||
May you do good and not evil.
|
||||
May you find forgiveness for yourself and forgive others.
|
||||
May you share freely, never taking more than you give.
|
||||
|
||||
===========================================================================
|
||||
|
||||
Mapbox GL uses portions of SVPulsingAnnotationView.
|
||||
|
||||
Copyright (c) 2013, Sam Vermette <hello@samvermette.com>
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
===========================================================================
|
||||
|
||||
Mapbox GL uses portions of zlib.
|
||||
|
||||
Acknowledgments:
|
||||
|
||||
The deflate format used by zlib was defined by Phil Katz. The deflate and
|
||||
zlib specifications were written by L. Peter Deutsch. Thanks to all the
|
||||
people who reported problems and suggested various improvements in zlib; they
|
||||
are too numerous to cite here.
|
||||
|
||||
Copyright notice:
|
||||
|
||||
(C) 1995-2013 Jean-loup Gailly and Mark Adler
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
|
||||
Jean-loup Gailly Mark Adler
|
||||
jloup@gzip.org madler@alumni.caltech.edu
|
||||
|
||||
289
Makefile
@@ -1,225 +1,108 @@
|
||||
BUILDTYPE ?= Release
|
||||
PYTHON ?= python
|
||||
PREFIX ?= /usr/local
|
||||
ANDROID_ABI ?= arm-v7
|
||||
export BUILDTYPE ?= Release
|
||||
export BUILD_TEST ?= 1
|
||||
export BUILD_RENDER ?= 1
|
||||
|
||||
# Determine build platform
|
||||
ifeq ($(shell uname -s), Darwin)
|
||||
HOST = osx
|
||||
HEADLESS = cgl
|
||||
JOBS ?= $(shell sysctl -n hw.ncpu)
|
||||
endif
|
||||
|
||||
ifeq ($(shell uname -s), Linux)
|
||||
HOST = linux
|
||||
JOBS ?= $(shell grep --count processor /proc/cpuinfo)
|
||||
BUILD_ROOT = $(shell pwd)
|
||||
endif
|
||||
|
||||
JOBS ?= 1
|
||||
|
||||
all: mbgl
|
||||
|
||||
include config/defaults.mk
|
||||
|
||||
#### Dependencies ##############################################################
|
||||
|
||||
# Wildcard targets get removed after build by default, but we want to preserve the config.
|
||||
.PRECIOUS: config/%.gypi
|
||||
config/%.gypi: CMD = ./configure config/$*.gypi
|
||||
config/%.gypi: configure
|
||||
@$(ENV_$*) ./scripts/flock.py build/Configure.lock ./configure config/$*.gypi
|
||||
|
||||
styles/styles:
|
||||
git submodule update --init styles
|
||||
|
||||
ifeq ($(shell uname -s), Darwin)
|
||||
SMCalloutView:
|
||||
git submodule update --init platform/ios/vendor/SMCalloutView
|
||||
export BUILD = osx
|
||||
export JOBS ?= $(shell sysctl -n hw.ncpu)
|
||||
export XCPRETTY := $(shell ./scripts/xcpretty.sh)
|
||||
else ifeq ($(shell uname -s), Linux)
|
||||
export BUILD = linux
|
||||
export JOBS ?= $(shell grep --count processor /proc/cpuinfo)
|
||||
else
|
||||
SMCalloutView:
|
||||
$(error Cannot determine build platform)
|
||||
endif
|
||||
export BUILD_VERSION = $(shell uname -m)
|
||||
|
||||
RUN = +@$(MAKE) -f scripts/main.mk
|
||||
|
||||
default: ; @printf "You must specify a valid target\n"
|
||||
|
||||
#### OS X targets ##############################################################
|
||||
|
||||
ifeq ($(BUILD),osx)
|
||||
.PHONY: osx xosx run-osx run-xosx
|
||||
osx: ; $(RUN) HOST=osx HOST_VERSION=x86_64 Makefile/osxapp
|
||||
xosx: ; $(RUN) HOST=osx HOST_VERSION=x86_64 Xcode/osxapp
|
||||
run-osx: osx ; @"build/osx-x86_64/$(BUILDTYPE)/Mapbox GL.app/Contents/MacOS/Mapbox GL"
|
||||
run-xosx: xosx ; @"gyp/build/$(BUILDTYPE)/Mapbox GL.app/Contents/MacOS/Mapbox GL"
|
||||
|
||||
.PHONY: Xcode/osx Xcode/ios
|
||||
Xcode/ios: ; $(RUN) HOST=ios Xcode/__project__
|
||||
Xcode/osx: ; $(RUN) HOST=osx HOST_VERSION=x86_64 Xcode/__project__
|
||||
|
||||
.PHONY: xproj iproj
|
||||
xproj: Xcode/osx ; @open ./build/osx-x86_64/gyp/osx.xcodeproj
|
||||
iproj: Xcode/ios ; @open ./build/ios-all/gyp/ios.xcodeproj
|
||||
|
||||
.PHONY: ios ibench isim
|
||||
ios ibench isim: export XCODEBUILD_ARGS += PROVISIONING_PROFILE="$$(PROVISIONING_PROFILE)"
|
||||
|
||||
ios: export XCODEBUILD_ARGS += -sdk iphoneos ARCHS="arm64 armv7 armv7s"
|
||||
ios: ; $(RUN) HOST=ios Xcode/iosapp
|
||||
|
||||
isim: export XCODEBUILD_ARGS += -sdk iphonesimulator ARCHS="x86_64 i386"
|
||||
isim: ; $(RUN) HOST=ios Xcode/iosapp
|
||||
|
||||
ibench: export XCODEBUILD_ARGS += -sdk iphoneos ARCHS="arm64"
|
||||
ibench: ; $(RUN) HOST=ios Xcode/ios-bench
|
||||
|
||||
.PHONY: ipackage ipackage-strip ipackage-sim itest
|
||||
ipackage: Xcode/ios ; @JOBS=$(JOBS) ./scripts/ios/package.sh
|
||||
ipackage-strip: Xcode/ios ; @JOBS=$(JOBS) ./scripts/ios/package.sh strip
|
||||
ipackage-sim: Xcode/ios ; @JOBS=$(JOBS) ./scripts/ios/package.sh sim
|
||||
itest: ipackage-sim ; ./scripts/ios/test.sh
|
||||
endif
|
||||
|
||||
geojsonvt:
|
||||
git submodule update --init src/mbgl/util/geojsonvt
|
||||
#### All platforms targets #####################################################
|
||||
|
||||
KIF:
|
||||
git submodule update --init test/ios/KIF
|
||||
.PHONY: linux run-linux run-valgrind-linux
|
||||
linux: ; $(RUN) Makefile/linuxapp
|
||||
run-linux: linux ; (cd build/linux-x86_64/$(BUILDTYPE) && ./mapbox-gl)
|
||||
run-valgrind-linux: linux
|
||||
(cd build/linux-x86_64/$(BUILDTYPE) && valgrind --leak-check=full --suppressions=../../../scripts/valgrind.sup ./mapbox-gl)
|
||||
|
||||
.PHONY: android android-lib
|
||||
# Builds a particular android architecture.
|
||||
android-lib-%: ; $(RUN) HOST=android HOST_VERSION=$* Makefile/androidapp
|
||||
|
||||
#### Build files ###############################################################
|
||||
# Builds the default Android library
|
||||
android-lib: ; $(RUN) HOST=android Makefile/androidapp
|
||||
|
||||
.PRECIOUS: Makefile/project
|
||||
Makefile/project: config/$(HOST).gypi styles/styles SMCalloutView geojsonvt
|
||||
deps/run_gyp gyp/$(HOST).gyp $(CONFIG_$(HOST)) $(LIBS_$(HOST)) --generator-output=./build/$(HOST) -f make
|
||||
# Builds the selected/default Android library
|
||||
android: android-lib
|
||||
cd android/java && ./gradlew --parallel --max-workers=$(JOBS) assemble$(BUILDTYPE)
|
||||
|
||||
.PRECIOUS: Xcode/project
|
||||
Xcode/project: config/$(HOST).gypi styles/styles SMCalloutView geojsonvt
|
||||
deps/run_gyp gyp/$(HOST).gyp $(CONFIG_$(HOST)) $(LIBS_$(HOST)) --generator-output=./build/$(HOST) -f xcode
|
||||
# Builds all android architectures for distribution.
|
||||
apackage: android-lib-arm-v5 android-lib-arm-v7
|
||||
apackage: android-lib-x86
|
||||
apackage: android-lib-mips
|
||||
cd android/java && ./gradlew --parallel-threads=$(JOBS) assemble$(BUILDTYPE)
|
||||
|
||||
|
||||
#### Library builds ############################################################
|
||||
|
||||
mbgl: Makefile/project
|
||||
$(MAKE) -C build/$(HOST) BUILDTYPE=$(BUILDTYPE) everything
|
||||
|
||||
standalone: Makefile/project
|
||||
LINK=`pwd`/gyp/link.py $(MAKE) -C build/$(HOST) BUILDTYPE=$(BUILDTYPE) standalone
|
||||
|
||||
install: Makefile/project
|
||||
LINK=`pwd`/gyp/link.py $(MAKE) -C build/$(HOST) BUILDTYPE=$(BUILDTYPE) install
|
||||
|
||||
|
||||
##### Test builds ##############################################################
|
||||
# Builds the Node.js library
|
||||
.PHONY: node
|
||||
node: ; $(RUN) HTTP=none ASSET=none CACHE=none Makefile/node
|
||||
|
||||
.PHONY: test
|
||||
test: Makefile/project
|
||||
$(MAKE) -C build/$(HOST) BUILDTYPE=$(BUILDTYPE) test
|
||||
test: ; $(RUN) Makefile/test
|
||||
test-%: ; $(RUN) test-$*
|
||||
ifeq ($(BUILD),osx)
|
||||
xtest: ; $(RUN) HOST=osx HOST_VERSION=x86_64 Xcode/test
|
||||
endif
|
||||
|
||||
test-%: test
|
||||
./scripts/run_tests.sh "build/$(HOST)/$(BUILDTYPE)/test" --gtest_filter=$*
|
||||
|
||||
.PHONY: xtest
|
||||
xtest: XCPRETTY := $(shell ./scripts/xcpretty.sh)
|
||||
xtest: Xcode/project
|
||||
xcodebuild -project ./build/osx/gyp/osx.xcodeproj -configuration $(BUILDTYPE) -target test -jobs $(JOBS) $(XCPRETTY)
|
||||
|
||||
xtest-%: xtest
|
||||
./scripts/run_tests.sh "build/osx/Build/Products/$(BUILDTYPE)/test" --gtest_filter=$*
|
||||
|
||||
|
||||
#### Mac OS X application builds ###############################################
|
||||
|
||||
.PHONY: osx run-osx
|
||||
osx: Makefile/project
|
||||
$(MAKE) -C build/osx BUILDTYPE=$(BUILDTYPE) osxapp
|
||||
|
||||
run-osx: osx
|
||||
"build/osx/$(BUILDTYPE)/Mapbox GL.app/Contents/MacOS/Mapbox GL"
|
||||
|
||||
run-valgrind-osx: osx
|
||||
(valgrind --leak-check=full --suppressions=scripts/valgrind.sup build/osx/$(BUILDTYPE)/Mapbox\ GL.app/Contents/MacOS/Mapbox\ GL)
|
||||
|
||||
.PHONY: xosx-proj xosx run-xosx
|
||||
xosx-proj: Xcode/project
|
||||
open ./build/osx/gyp/osx.xcodeproj
|
||||
|
||||
xosx: XCPRETTY := $(shell ./scripts/xcpretty.sh)
|
||||
xosx: Xcode/project
|
||||
xcodebuild -project ./build/osx/gyp/osx.xcodeproj -configuration $(BUILDTYPE) -target osxapp -jobs $(JOBS) $(XCPRETTY)
|
||||
|
||||
run-xosx: xosx
|
||||
"gyp/build/$(BUILDTYPE)/Mapbox GL.app/Contents/MacOS/Mapbox GL"
|
||||
|
||||
# Legacy name
|
||||
xproj: xosx-proj
|
||||
|
||||
|
||||
|
||||
#### iOS application builds ####################################################
|
||||
|
||||
.PRECIOUS: Xcode/ios
|
||||
Xcode/ios: gyp/ios.gyp config/ios.gypi styles/styles SMCalloutView geojsonvt
|
||||
deps/run_gyp gyp/ios.gyp $(CONFIG_ios) $(LIBS_ios) --generator-output=./build/ios -f xcode
|
||||
|
||||
.PHONY: ios-proj ios isim ipackage
|
||||
ios-proj: Xcode/ios
|
||||
open ./build/ios/gyp/ios.xcodeproj
|
||||
|
||||
ios: XCPRETTY := $(shell ./scripts/xcpretty.sh)
|
||||
ios: Xcode/ios
|
||||
xcodebuild -sdk iphoneos ARCHS="arm64 armv7 armv7s" PROVISIONING_PROFILE="19324a54-7455-4f0b-8e1c-e6957c718ebc" -project ./build/ios/gyp/ios.xcodeproj -configuration Release -target iosapp -jobs $(JOBS) $(XCPRETTY)
|
||||
|
||||
ibench: XCPRETTY := $(shell ./scripts/xcpretty.sh)
|
||||
ibench: Xcode/ios
|
||||
xcodebuild -sdk iphoneos ARCHS="arm64" PROVISIONING_PROFILE="19324a54-7455-4f0b-8e1c-e6957c718ebc" -project ./build/ios/gyp/ios.xcodeproj -configuration Release -target ios-bench -jobs $(JOBS) $(XCPRETTY)
|
||||
|
||||
isim: XCPRETTY := $(shell ./scripts/xcpretty.sh)
|
||||
isim: Xcode/ios
|
||||
xcodebuild -sdk iphonesimulator ARCHS="x86_64 i386" -project ./build/ios/gyp/ios.xcodeproj -configuration Debug -target iosapp -jobs $(JOBS) $(XCPRETTY)
|
||||
|
||||
ipackage: Xcode/ios
|
||||
JOBS=$(JOBS) ./scripts/ios/package.sh
|
||||
|
||||
ipackage-strip: Xcode/ios
|
||||
JOBS=$(JOBS) ./scripts/ios/package.sh strip
|
||||
|
||||
ipackage-sim: Xcode/ios
|
||||
JOBS=$(JOBS) ./scripts/ios/package.sh sim
|
||||
|
||||
itest: ipackage-sim KIF
|
||||
./scripts/ios/test.sh
|
||||
|
||||
# Legacy name
|
||||
iproj: ios-proj
|
||||
|
||||
|
||||
#### Linux application builds ##################################################
|
||||
|
||||
.PHONY: linux run-linux
|
||||
linux: Makefile/project
|
||||
$(MAKE) -C build/$(HOST) BUILDTYPE=$(BUILDTYPE) linuxapp
|
||||
|
||||
run-linux: linux
|
||||
(cd build/$(HOST)/$(BUILDTYPE) && ./mapbox-gl)
|
||||
|
||||
run-valgrind-linux: linux
|
||||
(cd build/$(HOST)/$(BUILDTYPE) && valgrind --leak-check=full --suppressions=$(BUILD_ROOT)/scripts/valgrind.sup ./mapbox-gl)
|
||||
|
||||
.PHONY: xlinux run-xlinux
|
||||
xlinux: XCPRETTY := $(shell ./scripts/xcpretty.sh)
|
||||
xlinux: Xcode/project
|
||||
xcodebuild -project ./build/osx/gyp/osx.xcodeproj -configuration $(BUILDTYPE) -target linuxapp -jobs $(JOBS) $(XCPRETTY)
|
||||
|
||||
run-xlinux: xlinux
|
||||
"gyp/build/$(BUILDTYPE)/mapbox-gl"
|
||||
|
||||
|
||||
#### Android libaries #########################################################
|
||||
|
||||
.PRECIOUS: Makefile/android-%
|
||||
Makefile/android-%: CMD = deps/run_gyp android/mapboxgl-app.gyp $(CONFIG_android-$*) $(LIBS_android) --generator-output=./build/android-$* -f make-android
|
||||
Makefile/android-%: config/android-%.gypi styles/styles geojsonvt
|
||||
@echo $(CMD)
|
||||
@$(ENV_android-$*) $(CMD)
|
||||
|
||||
# Builds a particular android architecture.
|
||||
android-lib-%: Makefile/android-%
|
||||
@$(ENV_android-$*) ./scripts/flock.py -v build/Android.lock $(MAKE) -C build/android-$* BUILDTYPE=$(BUILDTYPE) androidapp
|
||||
|
||||
# Builds the selected/default Android library
|
||||
android-lib: android-lib-$(ANDROID_ABI)
|
||||
|
||||
# Builds the selected/default Android library
|
||||
android: android-lib-$(ANDROID_ABI)
|
||||
cd android/java && ./gradlew --parallel-threads=$(JOBS) assemble$(BUILDTYPE)
|
||||
|
||||
# Builds all android architectures.
|
||||
android-all: $(ANDROID_ABIS)
|
||||
cd android/java && ./gradlew --parallel-threads=$(JOBS) assemble$(BUILDTYPE)
|
||||
|
||||
# Full build of GL Core for each architecture, build the Android Library, publish to Maven Central
|
||||
android-deploy: $(ANDROID_ABIS)
|
||||
cd android/java/MapboxGLAndroidSDK && chmod ugo+x deploy.sh && ./deploy.sh
|
||||
|
||||
android-project: android-lib
|
||||
|
||||
|
||||
##### Render builds ############################################################
|
||||
|
||||
render: Makefile/project
|
||||
$(MAKE) -C build/$(HOST) BUILDTYPE=$(BUILDTYPE) mbgl-render
|
||||
|
||||
.PHONY: xrender
|
||||
xrender: XCPRETTY := $(shell ./scripts/xcpretty.sh)
|
||||
xrender: Xcode/project
|
||||
xcodebuild -project ./build/osx/gyp/osx.xcodeproj -configuration $(BUILDTYPE) -target mbgl-render -jobs $(JOBS) $(XCPRETTY)
|
||||
.PHONY: render xrender
|
||||
render: ; $(RUN) Makefile/mbgl-render
|
||||
ifeq ($(BUILD),osx)
|
||||
xrender: ; $(RUN) HOST=osx HOST_VERSION=x86_64 Xcode/mbgl-render
|
||||
endif
|
||||
|
||||
|
||||
##### Maintenace operations ####################################################
|
||||
|
||||
.PHONY: clear_xcode_cache
|
||||
clear_xcode_cache:
|
||||
ifeq ($(PLATFORM), osx)
|
||||
ifeq ($(BUILD), osx)
|
||||
@CUSTOM_DD=`defaults read com.apple.dt.Xcode IDECustomDerivedDataLocation 2>/dev/null`; \
|
||||
if [ $$CUSTOM_DD ]; then \
|
||||
echo clearing files in $$CUSTOM_DD older than one day; \
|
||||
@@ -233,7 +116,7 @@ endif
|
||||
|
||||
.PHONY: clear_sqlite_cache
|
||||
clear_sqlite_cache:
|
||||
ifeq ($(PLATFORM), osx)
|
||||
ifeq ($(BUILD), osx)
|
||||
rm -f ~/Library/Application\ Support/Mapbox\ GL/cache.db
|
||||
else
|
||||
rm -f /tmp/mbgl-cache.db
|
||||
|
||||
279
README.md
@@ -1,276 +1,17 @@
|
||||
# Mapbox GL (Native)
|
||||
|
||||
[](https://travis-ci.org/mapbox/mapbox-gl-native/builds)
|
||||
|
||||
An OpenGL renderer for [Mapbox Vector Tiles](https://www.mapbox.com/blog/vector-tiles), consisting of a C++ library for OS X and Linux and SDK bindings for iOS and Android.
|
||||
An OpenGL ES-based renderer for [Mapbox Vector Tiles](https://www.mapbox.com/blog/vector-tiles), consisting of a C++ library for OS X and Linux and SDK bindings for iOS, Android and Node.js.
|
||||
|
||||
# Depends
|
||||
**This repository is for development on Mapbox GL itself.**
|
||||
|
||||
- Modern C++ compiler that supports `-std=c++14` (clang++ 3.5 or later or g++-4.9 or later)
|
||||
- [Boost headers](http://boost.org/)
|
||||
- [`zlib`](http://www.zlib.net/)
|
||||
- [`libpng`](http://www.libpng.org/pub/png/libpng.html)
|
||||
- [`libuv 0.10+`](https://github.com/joyent/libuv)
|
||||
- [`glfw 3.1+`](http://www.glfw.org/)
|
||||
- [`libcurl`](http://curl.haxx.se/libcurl/) (depends on OpenSSL; Linux only)
|
||||
- Apple Command Line Tools (for build on OS X; available at [Apple Developer](https://developer.apple.com/downloads))
|
||||
- `pkg-config` (for build only)
|
||||
- [Homebrew](http://brew.sh) (for building on OS X)
|
||||
- [xcpretty](https://github.com/supermarin/xcpretty) (for building on OS X)
|
||||
- [Cask](http://caskroom.io/) (for building Android on OS X)
|
||||
- Python 2.x (for build only)
|
||||
If you want to use products _based on_ Mapbox GL, check out:
|
||||
|
||||
# Build instructions
|
||||
- [Mapbox Mobile](http://mapbox.com/mobile) — iOS and Android native development libraries for vector maps in apps
|
||||
- [`react-native-mapbox-gl`](https://github.com/mapbox/react-native-mapbox-gl) — React Native library for vector maps in apps
|
||||
- [`qmapboxgl`](https://github.com/tmpsantos/qmapboxgl) — Qt library for vector map rendering
|
||||
|
||||
We try to link to as many system-provided libraries as possible. When these are unavailable or too outdated, we run a thin build-script layer called [Mason](https://github.com/mapbox/mason) to automate builds, and load precompiled binary packages when possible.
|
||||
--
|
||||
|
||||
Be sure to pull down all submodules first:
|
||||
|
||||
git submodule init
|
||||
git submodule update
|
||||
|
||||
## OS X
|
||||
|
||||
ImageMagick is required for tests. It's recommended to install it with [Homebrew](http://brew.sh/) via `brew install imagemagick`.
|
||||
|
||||
To create projects, you can run:
|
||||
|
||||
- `make xproj`: Creates an Xcode project with OS X-specific handlers for HTTP downloads and settings storage. It uses [GLFW](http://www.glfw.org) for window handling.
|
||||
- `make lproj`: Creates an Xcode project with platform-independent handlers for downloads and settings storage. This is what is also being built on Linux.
|
||||
- `make osx run-osx`: Builds and runs the OS X application on the command line with `xcodebuild`.
|
||||
- `make linux run-linux`: Builds and runs the Linux application with `make`.
|
||||
- `make test-*` Builds and runs all tests. You can specify individual tests by replacing * with their name.
|
||||
|
||||
Note that you can't have more than one project in Xcode open at a time since they the static library project is shared across the OS X, Linux and iOS project.
|
||||
|
||||
Target OS X: 10.9+
|
||||
|
||||
|
||||
## iOS
|
||||
|
||||
### Use
|
||||
|
||||
#### CocoaPods
|
||||
|
||||
[CocoaPods](https://cocoapods.org) is preferred. Put the following in your `Podfile`:
|
||||
|
||||
```ruby
|
||||
use_frameworks!
|
||||
pod 'MapboxGL'
|
||||
```
|
||||
|
||||
#### Manually
|
||||
|
||||
1. Install [appledoc](http://appledoc.gentlebytes.com/appledoc/) 2.2v963 for API docs generation (only this exact version works).
|
||||
|
||||
```
|
||||
curl -L -o appledoc.zip https://github.com/tomaz/appledoc/releases/download/v2.2-963/appledoc.zip
|
||||
unzip appledoc.zip
|
||||
cp appledoc /usr/local/bin
|
||||
cp -Rf Templates/ ~/.appledoc
|
||||
```
|
||||
|
||||
1. Run `make ipackage`. The packaging script will produce the statically-linked `libMapboxGL.a`, `MapboxGL.bundle` for resources, a `Headers` folder, and a `Docs` folder with HTML API documentation.
|
||||
1. Copy the contents of `build/ios/pkg/static` into your project. It should happen automatically, but ensure that:
|
||||
- `Headers` is in your *Header Search Paths* (`HEADER_SEARCH_PATHS`) build setting.
|
||||
- `MapboxGL.bundle` is in your target's *Copy Bundle Resources* build phase.
|
||||
- `libMapboxGL.a` is in your target's *Link Binary With Libraries* build phase.
|
||||
1. Add the following Cocoa framework dependencies to your target's *Link Binary With Libraries* build phase:
|
||||
- `CoreTelephony.framework`
|
||||
- `GLKit.framework`
|
||||
- `ImageIO.framework`
|
||||
- `MobileCoreServices.framework`
|
||||
- `QuartzCore.framework`
|
||||
- `SystemConfiguration.framework`
|
||||
- `libc++.dylib`
|
||||
- `libsqlite3.dylib`
|
||||
- `libz.dylib`
|
||||
1. Add `-ObjC` to your target's "Other Linker Flags" build setting (`OTHER_LDFLAGS`).
|
||||
1. [Set the Mapbox API access token](#mapbox-api-access-tokens).
|
||||
1. `#import "MapboxGL.h"`
|
||||
|
||||
### Development
|
||||
|
||||
If you want to build from source and/or contribute to development of the project, run `make iproj`, which will create and open an Xcode project which can build the entire library from source as well as an Objective-C test app. If you don't have an Apple Developer account, change the destination from "My Mac" to a simulator such as "iPhone 6" before you run and build the app.
|
||||
|
||||
#### Testing
|
||||
You can run `make itest` to run the included integration tests. Requires `gem install xcpretty`. If you want to run the tests in Xcode instead, first `make ipackage` to create a local static library version, then open `test/ios/ios-tests.xcodeproj`, and lastly `Command + U` on the `Mapbox GL Tests` application target.
|
||||
|
||||
Target devices: iPhone 4S and above (5, 5c, 5s, 6, 6 Plus) and iPad 2 and above (3, 4, Mini, Air, Mini 2, Air 2).
|
||||
|
||||
Target iOS: 7.0 through latest 8.x.
|
||||
|
||||
|
||||
## Linux
|
||||
|
||||
We are using Ubuntu for development. While the software should work on other distributions as well, we are not providing explicit build instructions here.
|
||||
|
||||
Install GCC 4.9+ if you are running Ubuntu 14.04 or older. Alternatively, you can also use [Clang 3.5+](http://llvm.org/apt/).
|
||||
|
||||
sudo add-apt-repository --yes ppa:ubuntu-toolchain-r/test
|
||||
sudo apt-get update
|
||||
sudo apt-get install gcc-4.9 g++-4.9
|
||||
export CXX=g++-4.9
|
||||
|
||||
Ensure you have git and other build essentials:
|
||||
|
||||
sudo apt-get install curl git build-essential zlib1g-dev automake \
|
||||
libtool xutils-dev make cmake pkg-config python-pip \
|
||||
libcurl4-openssl-dev libpng-dev libsqlite3-dev \
|
||||
libllvm3.4
|
||||
|
||||
Install glfw3 dependencies:
|
||||
|
||||
sudo apt-get install libxi-dev libglu1-mesa-dev x11proto-randr-dev \
|
||||
x11proto-xext-dev libxrandr-dev \
|
||||
x11proto-xf86vidmode-dev libxxf86vm-dev \
|
||||
libxcursor-dev libxinerama-dev
|
||||
|
||||
Then, you can then proceed to build the library:
|
||||
|
||||
git submodule update --init
|
||||
make linux
|
||||
|
||||
Set an access token as described below, and then run:
|
||||
|
||||
make run-linux
|
||||
|
||||
## Android
|
||||
|
||||
Target devices: All Android devices on Android 4.0 or newer (API level >= 14).
|
||||
|
||||
### On Linux
|
||||
|
||||
Install a few build dependencies:
|
||||
|
||||
apt-get install -y make git build-essential automake \
|
||||
libtool make cmake pkg-config lib32stdc++6 lib32z1
|
||||
|
||||
Install Oracle JDK 7 (requires license agreement) from http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html
|
||||
|
||||
export JAVA_HOME="/dir/to/jdk1.7.0_71"
|
||||
|
||||
Install the [Android NDK Revision 10e](https://developer.android.com/tools/sdk/ndk/index.html).
|
||||
|
||||
export ANDROID_NDK_PATH="/dir/to/android-ndk-r10e"
|
||||
|
||||
Install the Android SDK. We recommend doing this by way of [Android Studio](https://developer.android.com/sdk/installing/studio.html).
|
||||
|
||||
export ANDROID_HOME="/dir/to/android-sdk-linux"
|
||||
|
||||
Run:
|
||||
|
||||
make android
|
||||
|
||||
You can then open `android/java` in Android Studio via "Import Non-Android Studio Project".
|
||||
|
||||
### On OS X
|
||||
|
||||
Install Oracle JDK 7+:
|
||||
|
||||
brew cask install java
|
||||
|
||||
Install the [Android NDK Revision 10e](https://developer.android.com/tools/sdk/ndk/index.html) for 64-bit OS X:
|
||||
|
||||
brew install android-ndk
|
||||
|
||||
This will also install the dependency `android-sdk`.
|
||||
|
||||
Install [Android Studio](https://developer.android.com/sdk/installing/studio.html):
|
||||
|
||||
brew cask install android-studio
|
||||
android
|
||||
|
||||
By default, the SDK will be installed to `/usr/local/opt/android-sdk`. If you open Android Studio at this point, you may get an error message telling you that it can't find a JVM, it's because you installed a custom Java VM from Oracle. Follow [these instructions](http://tools.android.com/recent/androidstudio1rc3_releasecandidate3released) to start Android Studio. You'll wind up setting these environment variables in your .bash_profile or similar:
|
||||
|
||||
echo "export ANDROID_HOME=`brew --prefix android-sdk`" >> .bash_profile
|
||||
echo "export ANDROID_NDK_PATH=`brew --cellar android-ndk`/r10e" >> .bash_profile
|
||||
# Replace <path to JDK> with something like /Library/Java/JavaVirtualMachines/jdk1.8.0_31.jdk
|
||||
echo "export JAVA_HOME=<path to JDK>" >> .bash_profile
|
||||
echo "export STUDIO_JDK=$JAVA_HOME" >> .bash_profile
|
||||
|
||||
Run:
|
||||
|
||||
make android
|
||||
open -a Android\ Studio
|
||||
|
||||
You can then open `android/java` in Android Studio via "Import Non-Android Studio Project".
|
||||
|
||||
### Setting up Android emulator
|
||||
|
||||
If you want to run the test app in the emulator, we recommend the x86 build because it will run a lot faster.
|
||||
|
||||
First ensure you have an `MAPBOX_ACCESS_TOKEN` environment variable set, as described below. Then, create an x86 build:
|
||||
|
||||
ANDROID_ABI=x86 make android
|
||||
|
||||
In Android Studio, create an x86 AVD (Android Virtual Device):
|
||||
- Open AVD Manager via the Tools menu -> Android -> AVD Manager
|
||||
- Click "Create Virtual Device" at the bottom on AVD Manager window
|
||||
- Select one of the device profiles, for example the Nexus 4
|
||||
- Click "Next"
|
||||
- Select a Lollipop or Kitkat release with ABI of x86. If the line is greyed out click Download to download the OS files.
|
||||
- Click "Next"
|
||||
- Under "Emulated Performance" check "Host GPU" and uncheck "Store a snapshot for faster startup"
|
||||
- Click "Finish"
|
||||
- Close the AVD Manager
|
||||
|
||||
Now when you run or debug the Android project you will see a window "Choose Device". Select your new AVD from drop down under "Launch emulator". If you select "Use same device for future launches" Android Studio will remember the selection and not ask again.
|
||||
|
||||
### Running on a hardware device
|
||||
|
||||
First read the [Google documentation](http://developer.android.com/tools/device.html) to set up your device and your OS to connect to the device.
|
||||
|
||||
When you plug your device in and then run or debug the Android project you will see a window "Choose Device". Choose your device from the "Choose a running device" list.
|
||||
|
||||
If your device does not show you have not set it up properly, double check the [Google documentation](http://developer.android.com/tools/device.html).
|
||||
|
||||
# Troubleshooting
|
||||
|
||||
To trigger a complete rebuild, run `make clean` and then start over generating the Xcode projects or Makefiles as described above.
|
||||
|
||||
If you are having trouble getting the dependencies right, you can blow away the `mason_packages` directory, or run `make distclean`. This means the Makefile and configure script will automatically install the dependencies again on the next try.
|
||||
|
||||
On OS X, you can also try clearing the Xcode cache with `make clear_xcode_cache`.
|
||||
|
||||
# Mapbox API access tokens
|
||||
|
||||
The demo applications use Mapbox vector tiles, which **require a Mapbox account and API access token**. Obtain an access token on the [Mapbox account page](https://www.mapbox.com/account/apps/).
|
||||
|
||||
For iOS and OS X use of the demo apps in Xcode, setup the access token by editing the scheme for the application target, then adding an environment variable with the name `MAPBOX_ACCESS_TOKEN`.
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
For Linux, set the environment variable `MAPBOX_ACCESS_TOKEN` to your token.
|
||||
|
||||
For Android, gradle will take the value of `MAPBOX_ACCESS_TOKEN` and save it to `android/java/MapboxGLAndroidSDKTestApp/src/main/res/raw/token.txt` where the app will read it from.
|
||||
|
||||
# Style
|
||||
|
||||
Some styles in JSON format are included at `./styles`. See the [style spec](https://github.com/mapbox/mapbox-gl-style-spec) for more details.
|
||||
|
||||
# Usage
|
||||
|
||||
## Desktop
|
||||
|
||||
- Press `S` to cycle through bundled styles
|
||||
- Press `X` to reset the transform
|
||||
- Press `N` to reset north
|
||||
- Press `Tab` to toggle debug information
|
||||
- Press `C` to toggle symbol collision debug boxes
|
||||
- Press `Esc` to quit
|
||||
- Press `1` through `6` to add increasing numbers of point annotations for testing
|
||||
|
||||
## Mobile
|
||||
|
||||
- Pan to move
|
||||
- Pinch to zoom
|
||||
- Use two fingers to rotate
|
||||
- Double-tap to zoom in one level
|
||||
- Two-finger single-tap to zoom out one level
|
||||
- Double-tap, long-pressing the second, then pan up and down to "quick zoom" (iPhone only, meant for one-handed use)
|
||||
- Use the debug menu to add test annotations, reset position, and toggle debug info.
|
||||
|
||||
# Other notes
|
||||
|
||||
Under early development, this project was called LLMR (Low-Level Map Renderer), in case you see any lingering references to it.
|
||||
See [`INSTALL.md`](./INSTALL.md) for development setup and install instructions, including dependencies.
|
||||
|
||||
@@ -1,202 +0,0 @@
|
||||
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
@@ -1,13 +0,0 @@
|
||||
Android Gesture Detectors Framework Licence
|
||||
===================================
|
||||
|
||||
Copyright (c) 2012, Almer Thie
|
||||
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
@@ -1,13 +0,0 @@
|
||||
Copyright (c) 2014 Mapzen
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
@@ -15,6 +15,7 @@
|
||||
#include <mbgl/platform/event.hpp>
|
||||
#include <mbgl/platform/log.hpp>
|
||||
#include <mbgl/platform/gl.hpp>
|
||||
#include <mbgl/util/constants.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
namespace android {
|
||||
@@ -52,8 +53,11 @@ void log_gl_string(GLenum name, const char *label) {
|
||||
}
|
||||
}
|
||||
|
||||
NativeMapView::NativeMapView(JNIEnv *env, jobject obj_)
|
||||
NativeMapView::NativeMapView(JNIEnv *env, jobject obj_, float pixelRatio_, int availableProcessors_, size_t totalMemory_)
|
||||
: mbgl::View(*this),
|
||||
pixelRatio(pixelRatio_),
|
||||
availableProcessors(availableProcessors_),
|
||||
totalMemory(totalMemory_),
|
||||
fileCache(mbgl::android::cachePath + "/mbgl-cache.db"),
|
||||
fileSource(&fileCache),
|
||||
map(*this, fileSource, MapMode::Continuous) {
|
||||
@@ -98,6 +102,18 @@ NativeMapView::~NativeMapView() {
|
||||
vm = nullptr;
|
||||
}
|
||||
|
||||
float NativeMapView::getPixelRatio() const {
|
||||
return pixelRatio;
|
||||
}
|
||||
|
||||
std::array<uint16_t, 2> NativeMapView::getSize() const {
|
||||
return {{ static_cast<uint16_t>(width), static_cast<uint16_t>(height) }};
|
||||
}
|
||||
|
||||
std::array<uint16_t, 2> NativeMapView::getFramebufferSize() const {
|
||||
return {{ static_cast<uint16_t>(fbWidth), static_cast<uint16_t>(fbHeight) }};
|
||||
}
|
||||
|
||||
void NativeMapView::activate() {
|
||||
mbgl::Log::Debug(mbgl::Event::Android, "NativeMapView::activate");
|
||||
if ((display != EGL_NO_DISPLAY) && (surface != EGL_NO_SURFACE) && (context != EGL_NO_CONTEXT)) {
|
||||
@@ -132,41 +148,22 @@ void NativeMapView::invalidate() {
|
||||
assert(vm != nullptr);
|
||||
assert(obj != nullptr);
|
||||
|
||||
JavaVMAttachArgs args = {JNI_VERSION_1_2, "NativeMapView::invalidate()", NULL};
|
||||
|
||||
jint ret;
|
||||
JNIEnv *env = nullptr;
|
||||
bool detach = false;
|
||||
ret = vm->GetEnv(reinterpret_cast<void **>(&env), JNI_VERSION_1_6);
|
||||
if (ret != JNI_OK) {
|
||||
if (ret != JNI_EDETACHED) {
|
||||
mbgl::Log::Error(mbgl::Event::JNI, "GetEnv() failed with %i", ret);
|
||||
throw new std::runtime_error("GetEnv() failed");
|
||||
} else {
|
||||
ret = vm->AttachCurrentThread(&env, &args);
|
||||
if (ret != JNI_OK) {
|
||||
mbgl::Log::Error(mbgl::Event::JNI, "AttachCurrentThread() failed with %i", ret);
|
||||
throw new std::runtime_error("AttachCurrentThread() failed");
|
||||
}
|
||||
detach = true;
|
||||
}
|
||||
}
|
||||
bool detach = attach_jni_thread(vm, &env, "NativeMapView::invalidate()");
|
||||
|
||||
env->CallVoidMethod(obj, onInvalidateId);
|
||||
if (env->ExceptionCheck()) {
|
||||
env->ExceptionDescribe();
|
||||
}
|
||||
|
||||
if (detach) {
|
||||
if ((ret = vm->DetachCurrentThread()) != JNI_OK) {
|
||||
mbgl::Log::Error(mbgl::Event::JNI, "DetachCurrentThread() failed with %i", ret);
|
||||
throw new std::runtime_error("DetachCurrentThread() failed");
|
||||
}
|
||||
}
|
||||
env = nullptr;
|
||||
detach_jni_thread(vm, &env, detach);
|
||||
}
|
||||
|
||||
void NativeMapView::swap() {
|
||||
void NativeMapView::beforeRender() {
|
||||
// no-op
|
||||
}
|
||||
|
||||
void NativeMapView::afterRender() {
|
||||
mbgl::Log::Debug(mbgl::Event::Android, "NativeMapView::swap");
|
||||
|
||||
if ((display != EGL_NO_DISPLAY) && (surface != EGL_NO_SURFACE)) {
|
||||
@@ -640,44 +637,21 @@ void NativeMapView::resume() {
|
||||
}
|
||||
}
|
||||
|
||||
void NativeMapView::notifyMapChange(mbgl::MapChange) {
|
||||
void NativeMapView::notifyMapChange(mbgl::MapChange change) {
|
||||
mbgl::Log::Debug(mbgl::Event::Android, "NativeMapView::notifyMapChange()");
|
||||
|
||||
assert(vm != nullptr);
|
||||
assert(obj != nullptr);
|
||||
|
||||
JavaVMAttachArgs args = {JNI_VERSION_1_2, "NativeMapView::notifyMapChange()", NULL};
|
||||
|
||||
jint ret;
|
||||
JNIEnv *env = nullptr;
|
||||
bool detach = false;
|
||||
ret = vm->GetEnv(reinterpret_cast<void **>(&env), JNI_VERSION_1_6);
|
||||
if (ret != JNI_OK) {
|
||||
if (ret != JNI_EDETACHED) {
|
||||
mbgl::Log::Error(mbgl::Event::JNI, "GetEnv() failed with %i", ret);
|
||||
throw new std::runtime_error("GetEnv() failed");
|
||||
} else {
|
||||
ret = vm->AttachCurrentThread(&env, &args);
|
||||
if (ret != JNI_OK) {
|
||||
mbgl::Log::Error(mbgl::Event::JNI, "AttachCurrentThread() failed with %i", ret);
|
||||
throw new std::runtime_error("AttachCurrentThread() failed");
|
||||
}
|
||||
detach = true;
|
||||
}
|
||||
}
|
||||
bool detach = attach_jni_thread(vm, &env, "NativeMapView::notifyMapChange()");
|
||||
|
||||
env->CallVoidMethod(obj, onMapChangedId);
|
||||
env->CallVoidMethod(obj, onMapChangedId, change);
|
||||
if (env->ExceptionCheck()) {
|
||||
env->ExceptionDescribe();
|
||||
}
|
||||
|
||||
if (detach) {
|
||||
if ((ret = vm->DetachCurrentThread()) != JNI_OK) {
|
||||
mbgl::Log::Error(mbgl::Event::JNI, "DetachCurrentThread() failed with %i", ret);
|
||||
throw new std::runtime_error("DetachCurrentThread() failed");
|
||||
}
|
||||
}
|
||||
env = nullptr;
|
||||
detach_jni_thread(vm, &env, detach);
|
||||
}
|
||||
|
||||
void NativeMapView::enableFps(bool enable) {
|
||||
@@ -711,38 +685,15 @@ void NativeMapView::updateFps() {
|
||||
assert(vm != nullptr);
|
||||
assert(obj != nullptr);
|
||||
|
||||
JavaVMAttachArgs args = {JNI_VERSION_1_2, "NativeMapView::updateFps()", NULL};
|
||||
|
||||
jint ret;
|
||||
JNIEnv *env = nullptr;
|
||||
bool detach = false;
|
||||
ret = vm->GetEnv(reinterpret_cast<void **>(&env), JNI_VERSION_1_6);
|
||||
if (ret != JNI_OK) {
|
||||
if (ret != JNI_EDETACHED) {
|
||||
mbgl::Log::Error(mbgl::Event::JNI, "GetEnv() failed with %i", ret);
|
||||
throw new std::runtime_error("GetEnv() failed");
|
||||
} else {
|
||||
ret = vm->AttachCurrentThread(&env, &args);
|
||||
if (ret != JNI_OK) {
|
||||
mbgl::Log::Error(mbgl::Event::JNI, "AttachCurrentThread() failed with %i", ret);
|
||||
throw new std::runtime_error("AttachCurrentThread() failed");
|
||||
}
|
||||
detach = true;
|
||||
}
|
||||
}
|
||||
bool detach = attach_jni_thread(vm, &env, "NativeMapView::updateFps()");
|
||||
|
||||
env->CallVoidMethod(obj, onFpsChangedId, fps);
|
||||
if (env->ExceptionCheck()) {
|
||||
env->ExceptionDescribe();
|
||||
}
|
||||
|
||||
if (detach) {
|
||||
if ((ret = vm->DetachCurrentThread()) != JNI_OK) {
|
||||
mbgl::Log::Error(mbgl::Event::JNI, "DetachCurrentThread() failed with %i", ret);
|
||||
throw new std::runtime_error("DetachCurrentThread() failed");
|
||||
}
|
||||
}
|
||||
env = nullptr;
|
||||
detach_jni_thread(vm, &env, detach);
|
||||
}
|
||||
|
||||
void NativeMapView::onInvalidate() {
|
||||
@@ -750,9 +701,31 @@ void NativeMapView::onInvalidate() {
|
||||
|
||||
const bool dirty = !clean.test_and_set();
|
||||
if (dirty) {
|
||||
float zoomFactor = map.getMaxZoom() - map.getMinZoom() + 1;
|
||||
float cpuFactor = availableProcessors;
|
||||
float memoryFactor = static_cast<float>(totalMemory) / 1000.0f / 1000.0f / 1000.0f;
|
||||
float sizeFactor = (static_cast<float>(map.getWidth()) / mbgl::util::tileSize) *
|
||||
(static_cast<float>(map.getHeight()) / mbgl::util::tileSize);
|
||||
|
||||
size_t cacheSize = zoomFactor * cpuFactor * memoryFactor * sizeFactor * 0.5f;
|
||||
|
||||
map.setSourceTileCacheSize(cacheSize);
|
||||
|
||||
map.renderSync();
|
||||
}
|
||||
}
|
||||
|
||||
void NativeMapView::resizeView(int w, int h) {
|
||||
width = w;
|
||||
height = h;
|
||||
map.update(mbgl::Update::Dimensions);
|
||||
}
|
||||
|
||||
void NativeMapView::resizeFramebuffer(int w, int h) {
|
||||
fbWidth = w;
|
||||
fbHeight = h;
|
||||
map.update(mbgl::Update::Repaint);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
3
android/java/.gitignore
vendored
@@ -18,3 +18,6 @@ local.properties
|
||||
|
||||
# Token file
|
||||
MapboxGLAndroidSDKTestApp/src/main/res/raw/token.txt
|
||||
|
||||
# Twitter Fabric / Crashlytics
|
||||
fabric.properties
|
||||
|
||||
@@ -3,7 +3,7 @@ buildscript {
|
||||
mavenCentral()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:1.2.3'
|
||||
classpath 'com.android.tools.build:gradle:1.3.0'
|
||||
classpath 'com.jakewharton.sdkmanager:gradle-plugin:0.12.0'
|
||||
}
|
||||
}
|
||||
@@ -28,10 +28,11 @@ repositories {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile 'commons-validator:commons-validator:1.4.1'
|
||||
compile 'com.android.support:support-annotations:22.1.1'
|
||||
compile 'com.android.support:support-v4:22.1.1'
|
||||
compile 'com.squareup.okhttp:okhttp:2.3.0'
|
||||
compile 'com.android.support:support-annotations:23.0.1'
|
||||
compile 'com.android.support:support-v4:23.0.1'
|
||||
compile 'com.android.support:design:23.0.1'
|
||||
compile 'com.squareup.okhttp:okhttp:2.4.0'
|
||||
compile 'com.mapzen.android:lost:1.0.1'
|
||||
}
|
||||
|
||||
android {
|
||||
@@ -64,9 +65,8 @@ android {
|
||||
}
|
||||
|
||||
release {
|
||||
minifyEnabled false
|
||||
jniDebuggable false
|
||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
|
||||
consumerProguardFiles 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,10 +12,10 @@ POM_LICENCE_DIST=repo
|
||||
POM_DEVELOPER_ID=mapbox
|
||||
POM_DEVELOPER_NAME=Mapbox
|
||||
|
||||
ANDROID_MIN_SDK=8
|
||||
ANDROID_BUILD_TARGET_SDK_VERSION=22
|
||||
ANDROID_BUILD_TOOLS_VERSION=22.0.1
|
||||
ANDROID_BUILD_SDK_VERSION=22
|
||||
ANDROID_MIN_SDK=15
|
||||
ANDROID_BUILD_TARGET_SDK_VERSION=23
|
||||
ANDROID_BUILD_TOOLS_VERSION=23.0.1
|
||||
ANDROID_BUILD_SDK_VERSION=23
|
||||
|
||||
POM_NAME=Mapbox GL Android SDK
|
||||
POM_ARTIFACT_ID=mapbox-gl-android-sdk
|
||||
|
||||
24
android/java/MapboxGLAndroidSDK/proguard-rules.pro
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
# By default, the flags in this file are appended to flags specified
|
||||
# in ../sdk/tools/proguard/proguard-android.txt,
|
||||
# contents of this file will be appended into proguard-android.txt
|
||||
|
||||
# Square okio, ignoring warnings,
|
||||
# see https://github.com/square/okio/issues/60
|
||||
-dontwarn okio.**
|
||||
|
||||
# Package: annotations
|
||||
-keep class com.mapbox.mapboxgl.annotations.** { *; }
|
||||
|
||||
# Package: geometry
|
||||
-keep class com.mapbox.mapboxgl.geometry.** { *; }
|
||||
|
||||
# Package: http
|
||||
-keep class com.mapbox.mapboxgl.http.** { *; }
|
||||
|
||||
# Package views
|
||||
-keep class com.mapbox.mapboxgl.views.MapView**
|
||||
-keep class com.mapbox.mapboxgl.views.NativeMapView**
|
||||
-keepclassmembers class com.mapbox.mapboxgl.views.NativeMapView** {
|
||||
*;
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.mapbox.mapboxgl.views">
|
||||
|
||||
|
||||
<uses-feature android:glEsVersion="0x00020000" android:required="true" />
|
||||
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
|
||||
|
||||
@@ -1,150 +0,0 @@
|
||||
package com.almeros.android.multitouch;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.MotionEvent;
|
||||
|
||||
/**
|
||||
* @author Almer Thie (code.almeros.com)
|
||||
* Copyright (c) 2013, Almer Thie (code.almeros.com)
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer
|
||||
* in the documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
||||
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE.
|
||||
*/
|
||||
public abstract class BaseGestureDetector {
|
||||
protected final Context mContext;
|
||||
protected boolean mGestureInProgress;
|
||||
|
||||
protected MotionEvent mPrevEvent;
|
||||
protected MotionEvent mCurrEvent;
|
||||
|
||||
protected float mCurrPressure;
|
||||
protected float mPrevPressure;
|
||||
protected long mTimeDelta;
|
||||
|
||||
|
||||
/**
|
||||
* This value is the threshold ratio between the previous combined pressure
|
||||
* and the current combined pressure. When pressure decreases rapidly
|
||||
* between events the position values can often be imprecise, as it usually
|
||||
* indicates that the user is in the process of lifting a pointer off of the
|
||||
* device. This value was tuned experimentally.
|
||||
*/
|
||||
protected static final float PRESSURE_THRESHOLD = 0.67f;
|
||||
|
||||
|
||||
public BaseGestureDetector(Context context) {
|
||||
mContext = context;
|
||||
}
|
||||
|
||||
/**
|
||||
* All gesture detectors need to be called through this method to be able to
|
||||
* detect gestures. This method delegates work to handler methods
|
||||
* (handleStartProgressEvent, handleInProgressEvent) implemented in
|
||||
* extending classes.
|
||||
*
|
||||
* @param event MotionEvent
|
||||
* @return true
|
||||
*/
|
||||
public boolean onTouchEvent(MotionEvent event){
|
||||
final int actionCode = event.getAction() & MotionEvent.ACTION_MASK;
|
||||
if (!mGestureInProgress) {
|
||||
handleStartProgressEvent(actionCode, event);
|
||||
} else {
|
||||
handleInProgressEvent(actionCode, event);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the current event occurred when NO gesture is in progress
|
||||
* yet. The handling in this implementation may set the gesture in progress
|
||||
* (via mGestureInProgress) or out of progress
|
||||
* @param actionCode Action Code from MotionEvent
|
||||
* @param event MotionEvent
|
||||
*/
|
||||
protected abstract void handleStartProgressEvent(int actionCode, MotionEvent event);
|
||||
|
||||
/**
|
||||
* Called when the current event occurred when a gesture IS in progress. The
|
||||
* handling in this implementation may set the gesture out of progress (via
|
||||
* mGestureInProgress).
|
||||
* @param actionCode Action Code from MotionEvent
|
||||
* @param event MotionEvent
|
||||
*/
|
||||
protected abstract void handleInProgressEvent(int actionCode, MotionEvent event);
|
||||
|
||||
|
||||
protected void updateStateByEvent(MotionEvent curr){
|
||||
final MotionEvent prev = mPrevEvent;
|
||||
|
||||
// Reset mCurrEvent
|
||||
if (mCurrEvent != null) {
|
||||
mCurrEvent.recycle();
|
||||
mCurrEvent = null;
|
||||
}
|
||||
mCurrEvent = MotionEvent.obtain(curr);
|
||||
|
||||
|
||||
// Delta time
|
||||
mTimeDelta = curr.getEventTime() - prev.getEventTime();
|
||||
|
||||
// Pressure
|
||||
mCurrPressure = curr.getPressure(curr.getActionIndex());
|
||||
mPrevPressure = prev.getPressure(prev.getActionIndex());
|
||||
}
|
||||
|
||||
protected void resetState() {
|
||||
if (mPrevEvent != null) {
|
||||
mPrevEvent.recycle();
|
||||
mPrevEvent = null;
|
||||
}
|
||||
if (mCurrEvent != null) {
|
||||
mCurrEvent.recycle();
|
||||
mCurrEvent = null;
|
||||
}
|
||||
mGestureInProgress = false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns {@code true} if a gesture is currently in progress.
|
||||
* @return {@code true} if a gesture is currently in progress, {@code false} otherwise.
|
||||
*/
|
||||
public boolean isInProgress() {
|
||||
return mGestureInProgress;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the time difference in milliseconds between the previous accepted
|
||||
* GestureDetector event and the current GestureDetector event.
|
||||
*
|
||||
* @return Time difference since the last move event in milliseconds.
|
||||
*/
|
||||
public long getTimeDelta() {
|
||||
return mTimeDelta;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the event time of the current GestureDetector event being
|
||||
* processed.
|
||||
*
|
||||
* @return Current GestureDetector event time in milliseconds.
|
||||
*/
|
||||
public long getEventTime() {
|
||||
return mCurrEvent.getEventTime();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,174 +0,0 @@
|
||||
package com.almeros.android.multitouch;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.PointF;
|
||||
import android.view.MotionEvent;
|
||||
import com.almeros.android.multitouch.BaseGestureDetector;
|
||||
|
||||
/**
|
||||
* @author Almer Thie (code.almeros.com)
|
||||
* Copyright (c) 2013, Almer Thie (code.almeros.com)
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer
|
||||
* in the documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
||||
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE.
|
||||
*/
|
||||
public class MoveGestureDetector extends BaseGestureDetector {
|
||||
|
||||
/**
|
||||
* Listener which must be implemented which is used by MoveGestureDetector
|
||||
* to perform callbacks to any implementing class which is registered to a
|
||||
* MoveGestureDetector via the constructor.
|
||||
*
|
||||
* @see MoveGestureDetector.SimpleOnMoveGestureListener
|
||||
*/
|
||||
public interface OnMoveGestureListener {
|
||||
public boolean onMove(MoveGestureDetector detector);
|
||||
public boolean onMoveBegin(MoveGestureDetector detector);
|
||||
public void onMoveEnd(MoveGestureDetector detector);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper class which may be extended and where the methods may be
|
||||
* implemented. This way it is not necessary to implement all methods
|
||||
* of OnMoveGestureListener.
|
||||
*/
|
||||
public static class SimpleOnMoveGestureListener implements OnMoveGestureListener {
|
||||
public boolean onMove(MoveGestureDetector detector) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean onMoveBegin(MoveGestureDetector detector) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public void onMoveEnd(MoveGestureDetector detector) {
|
||||
// Do nothing, overridden implementation may be used
|
||||
}
|
||||
}
|
||||
|
||||
private static final PointF FOCUS_DELTA_ZERO = new PointF();
|
||||
|
||||
private final OnMoveGestureListener mListener;
|
||||
|
||||
private PointF mCurrFocusInternal;
|
||||
private PointF mPrevFocusInternal;
|
||||
private PointF mFocusExternal = new PointF();
|
||||
private PointF mFocusDeltaExternal = new PointF();
|
||||
|
||||
|
||||
public MoveGestureDetector(Context context, OnMoveGestureListener listener) {
|
||||
super(context);
|
||||
mListener = listener;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handleStartProgressEvent(int actionCode, MotionEvent event){
|
||||
switch (actionCode) {
|
||||
case MotionEvent.ACTION_DOWN:
|
||||
resetState(); // In case we missed an UP/CANCEL event
|
||||
|
||||
mPrevEvent = MotionEvent.obtain(event);
|
||||
mTimeDelta = 0;
|
||||
|
||||
updateStateByEvent(event);
|
||||
break;
|
||||
|
||||
case MotionEvent.ACTION_MOVE:
|
||||
mGestureInProgress = mListener.onMoveBegin(this);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handleInProgressEvent(int actionCode, MotionEvent event){
|
||||
switch (actionCode) {
|
||||
case MotionEvent.ACTION_UP:
|
||||
case MotionEvent.ACTION_CANCEL:
|
||||
mListener.onMoveEnd(this);
|
||||
resetState();
|
||||
break;
|
||||
|
||||
case MotionEvent.ACTION_MOVE:
|
||||
updateStateByEvent(event);
|
||||
|
||||
// Only accept the event if our relative pressure is within
|
||||
// a certain limit. This can help filter shaky data as a
|
||||
// finger is lifted.
|
||||
if (mCurrPressure / mPrevPressure > PRESSURE_THRESHOLD) {
|
||||
final boolean updatePrevious = mListener.onMove(this);
|
||||
if (updatePrevious) {
|
||||
mPrevEvent.recycle();
|
||||
mPrevEvent = MotionEvent.obtain(event);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
protected void updateStateByEvent(MotionEvent curr) {
|
||||
super.updateStateByEvent(curr);
|
||||
|
||||
final MotionEvent prev = mPrevEvent;
|
||||
|
||||
// Focus intenal
|
||||
mCurrFocusInternal = determineFocalPoint(curr);
|
||||
mPrevFocusInternal = determineFocalPoint(prev);
|
||||
|
||||
// Focus external
|
||||
// - Prevent skipping of focus delta when a finger is added or removed
|
||||
boolean mSkipNextMoveEvent = prev.getPointerCount() != curr.getPointerCount();
|
||||
mFocusDeltaExternal = mSkipNextMoveEvent ? FOCUS_DELTA_ZERO : new PointF(mCurrFocusInternal.x - mPrevFocusInternal.x, mCurrFocusInternal.y - mPrevFocusInternal.y);
|
||||
|
||||
// - Don't directly use mFocusInternal (or skipping will occur). Add
|
||||
// unskipped delta values to mFocusExternal instead.
|
||||
mFocusExternal.x += mFocusDeltaExternal.x;
|
||||
mFocusExternal.y += mFocusDeltaExternal.y;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine (multi)finger focal point (a.k.a. center point between all
|
||||
* fingers)
|
||||
*
|
||||
* @param MotionEvent e
|
||||
* @return PointF focal point
|
||||
*/
|
||||
private PointF determineFocalPoint(MotionEvent e){
|
||||
// Number of fingers on screen
|
||||
final int pCount = e.getPointerCount();
|
||||
float x = 0f;
|
||||
float y = 0f;
|
||||
|
||||
for(int i = 0; i < pCount; i++){
|
||||
x += e.getX(i);
|
||||
y += e.getY(i);
|
||||
}
|
||||
|
||||
return new PointF(x/pCount, y/pCount);
|
||||
}
|
||||
|
||||
public float getFocusX() {
|
||||
return mFocusExternal.x;
|
||||
}
|
||||
|
||||
public float getFocusY() {
|
||||
return mFocusExternal.y;
|
||||
}
|
||||
|
||||
public PointF getFocusDelta() {
|
||||
return mFocusDeltaExternal;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,169 +0,0 @@
|
||||
package com.almeros.android.multitouch;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.MotionEvent;
|
||||
|
||||
/**
|
||||
* @author Almer Thie (code.almeros.com)
|
||||
* Copyright (c) 2013, Almer Thie (code.almeros.com)
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer
|
||||
* in the documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
||||
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE.
|
||||
*/
|
||||
public class RotateGestureDetector extends TwoFingerGestureDetector {
|
||||
|
||||
/**
|
||||
* Listener which must be implemented which is used by RotateGestureDetector
|
||||
* to perform callbacks to any implementing class which is registered to a
|
||||
* RotateGestureDetector via the constructor.
|
||||
*
|
||||
* @see RotateGestureDetector.SimpleOnRotateGestureListener
|
||||
*/
|
||||
public interface OnRotateGestureListener {
|
||||
public boolean onRotate(RotateGestureDetector detector);
|
||||
public boolean onRotateBegin(RotateGestureDetector detector);
|
||||
public void onRotateEnd(RotateGestureDetector detector);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper class which may be extended and where the methods may be
|
||||
* implemented. This way it is not necessary to implement all methods
|
||||
* of OnRotateGestureListener.
|
||||
*/
|
||||
public static class SimpleOnRotateGestureListener implements OnRotateGestureListener {
|
||||
public boolean onRotate(RotateGestureDetector detector) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean onRotateBegin(RotateGestureDetector detector) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public void onRotateEnd(RotateGestureDetector detector) {
|
||||
// Do nothing, overridden implementation may be used
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private final OnRotateGestureListener mListener;
|
||||
private boolean mSloppyGesture;
|
||||
|
||||
public RotateGestureDetector(Context context, OnRotateGestureListener listener) {
|
||||
super(context);
|
||||
mListener = listener;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handleStartProgressEvent(int actionCode, MotionEvent event){
|
||||
switch (actionCode) {
|
||||
case MotionEvent.ACTION_POINTER_DOWN:
|
||||
// At least the second finger is on screen now
|
||||
|
||||
resetState(); // In case we missed an UP/CANCEL event
|
||||
mPrevEvent = MotionEvent.obtain(event);
|
||||
mTimeDelta = 0;
|
||||
|
||||
updateStateByEvent(event);
|
||||
|
||||
// See if we have a sloppy gesture
|
||||
mSloppyGesture = isSloppyGesture(event);
|
||||
if(!mSloppyGesture){
|
||||
// No, start gesture now
|
||||
mGestureInProgress = mListener.onRotateBegin(this);
|
||||
}
|
||||
break;
|
||||
|
||||
case MotionEvent.ACTION_MOVE:
|
||||
if (!mSloppyGesture) {
|
||||
break;
|
||||
}
|
||||
|
||||
// See if we still have a sloppy gesture
|
||||
mSloppyGesture = isSloppyGesture(event);
|
||||
if(!mSloppyGesture){
|
||||
// No, start normal gesture now
|
||||
mGestureInProgress = mListener.onRotateBegin(this);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case MotionEvent.ACTION_POINTER_UP:
|
||||
if (!mSloppyGesture) {
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void handleInProgressEvent(int actionCode, MotionEvent event){
|
||||
switch (actionCode) {
|
||||
case MotionEvent.ACTION_POINTER_UP:
|
||||
// Gesture ended but
|
||||
updateStateByEvent(event);
|
||||
|
||||
if (!mSloppyGesture) {
|
||||
mListener.onRotateEnd(this);
|
||||
}
|
||||
|
||||
resetState();
|
||||
break;
|
||||
|
||||
case MotionEvent.ACTION_CANCEL:
|
||||
if (!mSloppyGesture) {
|
||||
mListener.onRotateEnd(this);
|
||||
}
|
||||
|
||||
resetState();
|
||||
break;
|
||||
|
||||
case MotionEvent.ACTION_MOVE:
|
||||
updateStateByEvent(event);
|
||||
|
||||
// Only accept the event if our relative pressure is within
|
||||
// a certain limit. This can help filter shaky data as a
|
||||
// finger is lifted.
|
||||
if (mCurrPressure / mPrevPressure > PRESSURE_THRESHOLD) {
|
||||
final boolean updatePrevious = mListener.onRotate(this);
|
||||
if (updatePrevious) {
|
||||
mPrevEvent.recycle();
|
||||
mPrevEvent = MotionEvent.obtain(event);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void resetState() {
|
||||
super.resetState();
|
||||
mSloppyGesture = false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the rotation difference from the previous rotate event to the current
|
||||
* event.
|
||||
*
|
||||
* @return The current rotation //difference in degrees.
|
||||
*/
|
||||
public float getRotationDegreesDelta() {
|
||||
double diffRadians = Math.atan2(mPrevFingerDiffY, mPrevFingerDiffX) - Math.atan2(mCurrFingerDiffY, mCurrFingerDiffX);
|
||||
return (float) (diffRadians * 180 / Math.PI);
|
||||
}
|
||||
}
|
||||
@@ -1,202 +0,0 @@
|
||||
package com.almeros.android.multitouch;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.MotionEvent;
|
||||
|
||||
/**
|
||||
* @author Robert Nordan (robert.nordan@norkart.no)
|
||||
*
|
||||
* Copyright (c) 2013, Norkart AS
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer
|
||||
* in the documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
||||
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE.
|
||||
*/
|
||||
public class ShoveGestureDetector extends TwoFingerGestureDetector {
|
||||
|
||||
/**
|
||||
* Listener which must be implemented which is used by ShoveGestureDetector
|
||||
* to perform callbacks to any implementing class which is registered to a
|
||||
* ShoveGestureDetector via the constructor.
|
||||
*
|
||||
* @see ShoveGestureDetector.SimpleOnShoveGestureListener
|
||||
*/
|
||||
public interface OnShoveGestureListener {
|
||||
public boolean onShove(ShoveGestureDetector detector);
|
||||
public boolean onShoveBegin(ShoveGestureDetector detector);
|
||||
public void onShoveEnd(ShoveGestureDetector detector);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper class which may be extended and where the methods may be
|
||||
* implemented. This way it is not necessary to implement all methods
|
||||
* of OnShoveGestureListener.
|
||||
*/
|
||||
public static class SimpleOnShoveGestureListener implements OnShoveGestureListener {
|
||||
public boolean onShove(ShoveGestureDetector detector) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean onShoveBegin(ShoveGestureDetector detector) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public void onShoveEnd(ShoveGestureDetector detector) {
|
||||
// Do nothing, overridden implementation may be used
|
||||
}
|
||||
}
|
||||
|
||||
private float mPrevAverageY;
|
||||
private float mCurrAverageY;
|
||||
|
||||
private final OnShoveGestureListener mListener;
|
||||
private boolean mSloppyGesture;
|
||||
|
||||
public ShoveGestureDetector(Context context, OnShoveGestureListener listener) {
|
||||
super(context);
|
||||
mListener = listener;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handleStartProgressEvent(int actionCode, MotionEvent event){
|
||||
switch (actionCode) {
|
||||
case MotionEvent.ACTION_POINTER_DOWN:
|
||||
// At least the second finger is on screen now
|
||||
|
||||
resetState(); // In case we missed an UP/CANCEL event
|
||||
mPrevEvent = MotionEvent.obtain(event);
|
||||
mTimeDelta = 0;
|
||||
|
||||
updateStateByEvent(event);
|
||||
|
||||
// See if we have a sloppy gesture
|
||||
mSloppyGesture = isSloppyGesture(event);
|
||||
if(!mSloppyGesture){
|
||||
// No, start gesture now
|
||||
mGestureInProgress = mListener.onShoveBegin(this);
|
||||
}
|
||||
break;
|
||||
|
||||
case MotionEvent.ACTION_MOVE:
|
||||
if (!mSloppyGesture) {
|
||||
break;
|
||||
}
|
||||
|
||||
// See if we still have a sloppy gesture
|
||||
mSloppyGesture = isSloppyGesture(event);
|
||||
if(!mSloppyGesture){
|
||||
// No, start normal gesture now
|
||||
mGestureInProgress = mListener.onShoveBegin(this);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case MotionEvent.ACTION_POINTER_UP:
|
||||
if (!mSloppyGesture) {
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void handleInProgressEvent(int actionCode, MotionEvent event){
|
||||
switch (actionCode) {
|
||||
case MotionEvent.ACTION_POINTER_UP:
|
||||
// Gesture ended but
|
||||
updateStateByEvent(event);
|
||||
|
||||
if (!mSloppyGesture) {
|
||||
mListener.onShoveEnd(this);
|
||||
}
|
||||
|
||||
resetState();
|
||||
break;
|
||||
|
||||
case MotionEvent.ACTION_CANCEL:
|
||||
if (!mSloppyGesture) {
|
||||
mListener.onShoveEnd(this);
|
||||
}
|
||||
|
||||
resetState();
|
||||
break;
|
||||
|
||||
case MotionEvent.ACTION_MOVE:
|
||||
updateStateByEvent(event);
|
||||
|
||||
// Only accept the event if our relative pressure is within
|
||||
// a certain limit. This can help filter shaky data as a
|
||||
// finger is lifted. Also check that shove is meaningful.
|
||||
if (mCurrPressure / mPrevPressure > PRESSURE_THRESHOLD
|
||||
&& Math.abs(getShovePixelsDelta()) > 0.5f) {
|
||||
final boolean updatePrevious = mListener.onShove(this);
|
||||
if (updatePrevious) {
|
||||
mPrevEvent.recycle();
|
||||
mPrevEvent = MotionEvent.obtain(event);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void resetState() {
|
||||
super.resetState();
|
||||
mSloppyGesture = false;
|
||||
mPrevAverageY = 0.0f;
|
||||
mCurrAverageY = 0.0f;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateStateByEvent(MotionEvent curr){
|
||||
super.updateStateByEvent(curr);
|
||||
|
||||
final MotionEvent prev = mPrevEvent;
|
||||
float py0 = prev.getY(0);
|
||||
float py1 = prev.getY(1);
|
||||
mPrevAverageY = (py0 + py1) / 2.0f;
|
||||
|
||||
float cy0 = curr.getY(0);
|
||||
float cy1 = curr.getY(1);
|
||||
mCurrAverageY = (cy0 + cy1) / 2.0f;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isSloppyGesture(MotionEvent event){
|
||||
boolean sloppy = super.isSloppyGesture(event);
|
||||
if (sloppy)
|
||||
return true;
|
||||
|
||||
// If it's not traditionally sloppy, we check if the angle between fingers
|
||||
// is acceptable.
|
||||
double angle = Math.abs(Math.atan2(mCurrFingerDiffY, mCurrFingerDiffX));
|
||||
//about 20 degrees, left or right
|
||||
return !(( 0.0f < angle && angle < 0.35f)
|
||||
|| 2.79f < angle && angle < Math.PI);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the distance in pixels from the previous shove event to the current
|
||||
* event.
|
||||
*
|
||||
* @return The current distance in pixels.
|
||||
*/
|
||||
public float getShovePixelsDelta() {
|
||||
return mCurrAverageY - mPrevAverageY;
|
||||
}
|
||||
}
|
||||
@@ -1,179 +0,0 @@
|
||||
package com.almeros.android.multitouch;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.ViewConfiguration;
|
||||
|
||||
/**
|
||||
* @author Almer Thie (code.almeros.com)
|
||||
* Copyright (c) 2013, Almer Thie (code.almeros.com)
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer
|
||||
* in the documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
||||
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE.
|
||||
*/
|
||||
public abstract class TwoFingerGestureDetector extends BaseGestureDetector {
|
||||
|
||||
private final float mEdgeSlop;
|
||||
private float mRightSlopEdge;
|
||||
private float mBottomSlopEdge;
|
||||
|
||||
protected float mPrevFingerDiffX;
|
||||
protected float mPrevFingerDiffY;
|
||||
protected float mCurrFingerDiffX;
|
||||
protected float mCurrFingerDiffY;
|
||||
|
||||
private float mCurrLen;
|
||||
private float mPrevLen;
|
||||
|
||||
public TwoFingerGestureDetector(Context context) {
|
||||
super(context);
|
||||
|
||||
ViewConfiguration config = ViewConfiguration.get(context);
|
||||
mEdgeSlop = config.getScaledEdgeSlop();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected abstract void handleStartProgressEvent(int actionCode, MotionEvent event);
|
||||
|
||||
@Override
|
||||
protected abstract void handleInProgressEvent(int actionCode, MotionEvent event);
|
||||
|
||||
protected void updateStateByEvent(MotionEvent curr){
|
||||
super.updateStateByEvent(curr);
|
||||
|
||||
final MotionEvent prev = mPrevEvent;
|
||||
|
||||
mCurrLen = -1;
|
||||
mPrevLen = -1;
|
||||
|
||||
// Previous
|
||||
final float px0 = prev.getX(0);
|
||||
final float py0 = prev.getY(0);
|
||||
final float px1 = prev.getX(1);
|
||||
final float py1 = prev.getY(1);
|
||||
final float pvx = px1 - px0;
|
||||
final float pvy = py1 - py0;
|
||||
mPrevFingerDiffX = pvx;
|
||||
mPrevFingerDiffY = pvy;
|
||||
|
||||
// Current
|
||||
final float cx0 = curr.getX(0);
|
||||
final float cy0 = curr.getY(0);
|
||||
final float cx1 = curr.getX(1);
|
||||
final float cy1 = curr.getY(1);
|
||||
final float cvx = cx1 - cx0;
|
||||
final float cvy = cy1 - cy0;
|
||||
mCurrFingerDiffX = cvx;
|
||||
mCurrFingerDiffY = cvy;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the current distance between the two pointers forming the
|
||||
* gesture in progress.
|
||||
*
|
||||
* @return Distance between pointers in pixels.
|
||||
*/
|
||||
public float getCurrentSpan() {
|
||||
if (mCurrLen == -1) {
|
||||
final float cvx = mCurrFingerDiffX;
|
||||
final float cvy = mCurrFingerDiffY;
|
||||
mCurrLen = (float)Math.sqrt(cvx*cvx + cvy*cvy);
|
||||
}
|
||||
return mCurrLen;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the previous distance between the two pointers forming the
|
||||
* gesture in progress.
|
||||
*
|
||||
* @return Previous distance between pointers in pixels.
|
||||
*/
|
||||
public float getPreviousSpan() {
|
||||
if (mPrevLen == -1) {
|
||||
final float pvx = mPrevFingerDiffX;
|
||||
final float pvy = mPrevFingerDiffY;
|
||||
mPrevLen = (float)Math.sqrt(pvx*pvx + pvy*pvy);
|
||||
}
|
||||
return mPrevLen;
|
||||
}
|
||||
|
||||
/**
|
||||
* MotionEvent has no getRawX(int) method; simulate it pending future API approval.
|
||||
* @param event
|
||||
* @param pointerIndex
|
||||
* @return Raw X value or 0
|
||||
*/
|
||||
protected static float getRawX(MotionEvent event, int pointerIndex) {
|
||||
float offset = event.getX() - event.getRawX();
|
||||
if(pointerIndex < event.getPointerCount()){
|
||||
return event.getX(pointerIndex) + offset;
|
||||
}
|
||||
return 0f;
|
||||
}
|
||||
|
||||
/**
|
||||
* MotionEvent has no getRawY(int) method; simulate it pending future API approval.
|
||||
* @param event
|
||||
* @param pointerIndex
|
||||
* @return Raw Y value or 0
|
||||
*/
|
||||
protected static float getRawY(MotionEvent event, int pointerIndex) {
|
||||
float offset = event.getY() - event.getRawY();
|
||||
if(pointerIndex < event.getPointerCount()){
|
||||
return event.getY(pointerIndex) + offset;
|
||||
}
|
||||
return 0f;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if we have a sloppy gesture. Sloppy gestures can happen if the edge
|
||||
* of the user's hand is touching the screen, for example.
|
||||
*
|
||||
* @param event MotionEvent
|
||||
* @return {@code true} if is a sloppy gesture, {@code false} if not
|
||||
*/
|
||||
protected boolean isSloppyGesture(MotionEvent event){
|
||||
// As orientation can change, query the metrics in touch down
|
||||
DisplayMetrics metrics = mContext.getResources().getDisplayMetrics();
|
||||
mRightSlopEdge = metrics.widthPixels - mEdgeSlop;
|
||||
mBottomSlopEdge = metrics.heightPixels - mEdgeSlop;
|
||||
|
||||
final float edgeSlop = mEdgeSlop;
|
||||
final float rightSlop = mRightSlopEdge;
|
||||
final float bottomSlop = mBottomSlopEdge;
|
||||
|
||||
final float x0 = event.getRawX();
|
||||
final float y0 = event.getRawY();
|
||||
final float x1 = getRawX(event, 1);
|
||||
final float y1 = getRawY(event, 1);
|
||||
|
||||
boolean p0sloppy = x0 < edgeSlop || y0 < edgeSlop
|
||||
|| x0 > rightSlop || y0 > bottomSlop;
|
||||
boolean p1sloppy = x1 < edgeSlop || y1 < edgeSlop
|
||||
|| x1 > rightSlop || y1 > bottomSlop;
|
||||
|
||||
if (p0sloppy && p1sloppy) {
|
||||
return true;
|
||||
} else if (p0sloppy) {
|
||||
return true;
|
||||
} else if (p1sloppy) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
package com.mapbox.mapboxgl.annotations;
|
||||
|
||||
import com.mapbox.mapboxgl.views.MapView;
|
||||
|
||||
public abstract class Annotation implements Comparable<Annotation> {
|
||||
|
||||
/**
|
||||
* The annotation id
|
||||
*
|
||||
* Internal C++ id is stored as unsigned int.
|
||||
*/
|
||||
protected long id = -1; // -1 unless added to a MapView
|
||||
protected MapView mapView;
|
||||
|
||||
float alpha = 1.0f;
|
||||
boolean visible = true;
|
||||
|
||||
public Annotation() {}
|
||||
|
||||
public float getAlpha() {
|
||||
return alpha;
|
||||
}
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public boolean isVisible() {
|
||||
return visible;
|
||||
}
|
||||
|
||||
public void remove() {
|
||||
if (mapView == null) return;
|
||||
mapView.removeAnnotation(this);
|
||||
}
|
||||
|
||||
public void setAlpha(float alpha) {
|
||||
this.alpha = alpha;
|
||||
}
|
||||
|
||||
public void setId(long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public void setMapView(MapView mapView) {
|
||||
this.mapView = mapView;
|
||||
}
|
||||
|
||||
public void setVisible(boolean visible) {
|
||||
this.visible = visible;
|
||||
}
|
||||
|
||||
// TODO: Implement getZIndex of Google Maps Android API
|
||||
// public float getZIndex() {
|
||||
//
|
||||
// }
|
||||
|
||||
// TODO: Implement setZIndex of Google Maps Android API
|
||||
// public void setZIndex(float zIndex) {
|
||||
//
|
||||
// }
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (o == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (o instanceof Annotation) {
|
||||
Annotation comp = (Annotation) o;
|
||||
return id == comp.id;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(Annotation annotation) {
|
||||
|
||||
if (annotation == null) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (id < annotation.getId()) {
|
||||
return 1;
|
||||
} else if (id > annotation.getId()) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Equal
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.mapbox.mapboxgl.annotations;
|
||||
|
||||
public abstract class AnnotationOptions {
|
||||
|
||||
protected Annotation annotation;
|
||||
|
||||
public AnnotationOptions() {}
|
||||
|
||||
public AnnotationOptions alpha(float alpha) {
|
||||
annotation.alpha = alpha;
|
||||
return this;
|
||||
}
|
||||
|
||||
public float getAlpha() {
|
||||
return annotation.alpha;
|
||||
}
|
||||
|
||||
public boolean isVisible() {
|
||||
return annotation.visible;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
package com.mapbox.mapboxgl.annotations;
|
||||
|
||||
|
||||
import android.graphics.Color;
|
||||
|
||||
import com.mapbox.mapboxgl.geometry.LatLng;
|
||||
|
||||
/**
|
||||
* UNIMPLEMENTED: Needs implementation in Native.
|
||||
*
|
||||
* https://github.com/mapbox/mapbox-gl-native/issues/1882
|
||||
* https://github.com/mapbox/mapbox-gl-native/issues/1726
|
||||
*/
|
||||
public class Circle extends Annotation {
|
||||
|
||||
LatLng center;
|
||||
int fillColor = Color.BLACK;
|
||||
double radius;
|
||||
int strokeColor = Color.BLACK;
|
||||
float strokeWidth = 10; // Google Maps API defaults to 10
|
||||
|
||||
public LatLng getCenter() {
|
||||
return center;
|
||||
}
|
||||
|
||||
public int getFillColor() {
|
||||
return fillColor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the circle's radius, in meters.
|
||||
*
|
||||
* @return radius in meters
|
||||
*/
|
||||
public double getRadius() {
|
||||
return radius;
|
||||
}
|
||||
|
||||
public int getStrokeColor() {
|
||||
return strokeColor;
|
||||
}
|
||||
|
||||
public float getStrokeWidth() {
|
||||
return strokeWidth;
|
||||
}
|
||||
|
||||
public void setCenter(LatLng center) {
|
||||
this.center = center;
|
||||
}
|
||||
|
||||
public void setFillColor(int color) {
|
||||
fillColor = color;
|
||||
}
|
||||
|
||||
public void setRadius(double radius) {
|
||||
this.radius = radius;
|
||||
}
|
||||
|
||||
public void setStrokeColor (int color) {
|
||||
strokeColor = color;
|
||||
}
|
||||
|
||||
public void setStrokeWidth (float width) {
|
||||
strokeWidth = width;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package com.mapbox.mapboxgl.annotations;
|
||||
|
||||
|
||||
import com.mapbox.mapboxgl.geometry.LatLng;
|
||||
|
||||
/**
|
||||
* UNIMPLEMENTED: Needs implementation in Native.
|
||||
*
|
||||
* https://github.com/mapbox/mapbox-gl-native/issues/1882
|
||||
* https://github.com/mapbox/mapbox-gl-native/issues/1726
|
||||
*/
|
||||
public class CircleOptions extends AnnotationOptions {
|
||||
|
||||
private Circle circle;
|
||||
|
||||
public CircleOptions() {
|
||||
circle = new Circle();
|
||||
}
|
||||
public CircleOptions center(LatLng center) {
|
||||
circle.center = center;
|
||||
return this;
|
||||
}
|
||||
|
||||
public CircleOptions fillColor(int color) {
|
||||
circle.fillColor = color;
|
||||
return this;
|
||||
}
|
||||
|
||||
public LatLng getCenter() {
|
||||
return circle.center;
|
||||
}
|
||||
|
||||
public int getFillColor() {
|
||||
return circle.fillColor;
|
||||
}
|
||||
|
||||
public double getRadius() {
|
||||
return circle.radius;
|
||||
}
|
||||
|
||||
public int getStrokeColor () {
|
||||
return circle.strokeColor;
|
||||
}
|
||||
|
||||
public float getStrokeWidth() {
|
||||
return circle.strokeWidth;
|
||||
}
|
||||
|
||||
public CircleOptions radius (double radius) {
|
||||
circle.radius = radius;
|
||||
return this;
|
||||
}
|
||||
|
||||
public CircleOptions strokeColor(int color) {
|
||||
circle.strokeColor = color;
|
||||
return this;
|
||||
}
|
||||
|
||||
public CircleOptions strokeWidth (float width) {
|
||||
circle.strokeWidth = width;
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,199 @@
|
||||
package com.mapbox.mapboxgl.annotations;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.PointF;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
import com.mapbox.mapboxgl.geometry.LatLng;
|
||||
import com.mapbox.mapboxgl.views.MapView;
|
||||
|
||||
/**
|
||||
* A tooltip view
|
||||
*/
|
||||
public class InfoWindow {
|
||||
|
||||
private Marker boundMarker;
|
||||
private MapView mMapView;
|
||||
private boolean mIsVisible;
|
||||
protected View mView;
|
||||
|
||||
static int mTitleId = 0;
|
||||
static int mDescriptionId = 0;
|
||||
static int mSubDescriptionId = 0;
|
||||
static int mImageId = 0;
|
||||
|
||||
public InfoWindow(int layoutResId, MapView mapView) {
|
||||
mMapView = mapView;
|
||||
mIsVisible = false;
|
||||
Context context = mapView.getContext();
|
||||
LayoutInflater inflater =
|
||||
(LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
mView = inflater.inflate(layoutResId, (ViewGroup) mapView, false);
|
||||
|
||||
if (mTitleId == 0) {
|
||||
setResIds(mapView.getContext());
|
||||
}
|
||||
|
||||
// default behavior: close it when clicking on the tooltip:
|
||||
setOnTouchListener(new View.OnTouchListener() {
|
||||
@Override
|
||||
public boolean onTouch(View v, MotionEvent e) {
|
||||
if (e.getAction() == MotionEvent.ACTION_UP) {
|
||||
close();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public InfoWindow(View view, MapView mapView) {
|
||||
mMapView = mapView;
|
||||
mIsVisible = false;
|
||||
ViewGroup parent = (ViewGroup) mapView.getParent();
|
||||
Context context = mapView.getContext();
|
||||
LayoutInflater inflater =
|
||||
(LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
mView = view;
|
||||
|
||||
// default behavior: close it when clicking on the tooltip:
|
||||
setOnTouchListener(new View.OnTouchListener() {
|
||||
@Override
|
||||
public boolean onTouch(View v, MotionEvent e) {
|
||||
if (e.getAction() == MotionEvent.ACTION_UP) {
|
||||
close();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* open the window at the specified position.
|
||||
*
|
||||
* @param object the graphical object on which is hooked the view
|
||||
* @param position to place the window on the map
|
||||
* @param offsetX (&offsetY) the offset of the view to the position, in pixels.
|
||||
* This allows to offset the view from the object position.
|
||||
* @return this infowindow
|
||||
*/
|
||||
public InfoWindow open(Marker object, LatLng position, int offsetX, int offsetY) {
|
||||
onOpen(object);
|
||||
MapView.LayoutParams lp = new MapView.LayoutParams(MapView.LayoutParams.WRAP_CONTENT, MapView.LayoutParams.WRAP_CONTENT);
|
||||
mView.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED);
|
||||
|
||||
PointF coords = mMapView.toScreenLocation(position);
|
||||
double y = mMapView.getTopOffsetPixelsForAnnotationSymbol(object.sprite);
|
||||
y = y * mMapView.getScreenDensity();
|
||||
|
||||
// Flip y coordinate as Android view origin is upper left corner
|
||||
coords.y = mMapView.getHeight() - coords.y;
|
||||
lp.leftMargin = (int) coords.x - (mView.getMeasuredWidth() / 2);
|
||||
// Add y because it's a negative value
|
||||
lp.topMargin = (int) coords.y - mView.getMeasuredHeight() + (int) y;
|
||||
|
||||
close(); //if it was already opened
|
||||
mMapView.addView(mView, lp);
|
||||
mIsVisible = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Close this InfoWindow if it is visible, otherwise don't do anything.
|
||||
*
|
||||
* @return this info window
|
||||
*/
|
||||
public InfoWindow close() {
|
||||
if (mIsVisible) {
|
||||
mIsVisible = false;
|
||||
((ViewGroup) mView.getParent()).removeView(mView);
|
||||
// this.boundMarker.blur();
|
||||
setBoundMarker(null);
|
||||
onClose();
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Android view. This allows to set its content.
|
||||
*
|
||||
* @return the Android view
|
||||
*/
|
||||
public View getView() {
|
||||
return mView;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the mapView this InfoWindow is bound to
|
||||
*
|
||||
* @return the mapView
|
||||
*/
|
||||
public MapView getMapView() {
|
||||
return mMapView;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs the view that is displayed when the InfoWindow opens.
|
||||
* This retrieves data from overlayItem and shows it in the tooltip.
|
||||
*
|
||||
* @param overlayItem the tapped overlay item
|
||||
*/
|
||||
public void onOpen(Marker overlayItem) {
|
||||
String title = overlayItem.getTitle();
|
||||
((TextView) mView.findViewById(mTitleId /*R.id.title*/)).setText(title);
|
||||
String snippet = overlayItem.getSnippet();
|
||||
((TextView) mView.findViewById(mDescriptionId /*R.id.description*/)).setText(snippet);
|
||||
|
||||
/*
|
||||
//handle sub-description, hiding or showing the text view:
|
||||
TextView subDescText = (TextView) mView.findViewById(mSubDescriptionId);
|
||||
String subDesc = overlayItem.getSubDescription();
|
||||
if ("".equals(subDesc)) {
|
||||
subDescText.setVisibility(View.GONE);
|
||||
} else {
|
||||
subDescText.setText(subDesc);
|
||||
subDescText.setVisibility(View.VISIBLE);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
public void onClose() {
|
||||
//by default, do nothing
|
||||
}
|
||||
|
||||
public InfoWindow setBoundMarker(Marker aBoundMarker) {
|
||||
this.boundMarker = aBoundMarker;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Marker getBoundMarker() {
|
||||
return boundMarker;
|
||||
}
|
||||
|
||||
/**
|
||||
* Given a context, set the resource ids for the layout
|
||||
* of the InfoWindow.
|
||||
*
|
||||
* @param context
|
||||
*/
|
||||
private static void setResIds(Context context) {
|
||||
String packageName = context.getPackageName(); //get application package name
|
||||
mTitleId = context.getResources().getIdentifier("id/infowindow_title", null, packageName);
|
||||
mDescriptionId =
|
||||
context.getResources().getIdentifier("id/infowindow_description", null, packageName);
|
||||
mSubDescriptionId = context.getResources()
|
||||
.getIdentifier("id/infowindow_subdescription", null, packageName);
|
||||
mImageId = context.getResources().getIdentifier("id/infowindow_image", null, packageName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Use to override default touch events handling on InfoWindow (ie, close automatically)
|
||||
*
|
||||
* @param listener New View.OnTouchListener to use
|
||||
*/
|
||||
public void setOnTouchListener(View.OnTouchListener listener) {
|
||||
mView.setOnTouchListener(listener);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.mapbox.mapboxgl.annotations;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.Path;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
|
||||
public class InfoWindowTipView extends View {
|
||||
|
||||
private Paint mPaint;
|
||||
private Path mPath;
|
||||
|
||||
public InfoWindowTipView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
|
||||
mPath = new Path();
|
||||
|
||||
this.mPaint = new Paint();
|
||||
this.mPaint.setColor(Color.WHITE);
|
||||
this.mPaint.setAntiAlias(true);
|
||||
this.mPaint.setStrokeWidth(0.0f);
|
||||
this.mPaint.setStyle(Paint.Style.FILL);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDraw(Canvas canvas) {
|
||||
int height = getMeasuredHeight();
|
||||
int width = getMeasuredWidth();
|
||||
|
||||
mPath.rewind();
|
||||
mPath.moveTo((width / 2) - height, 0);
|
||||
mPath.lineTo((width / 2) + height, 0);
|
||||
mPath.lineTo((width / 2), height);
|
||||
mPath.lineTo((width / 2) - height, 0);
|
||||
canvas.drawPath(mPath, this.mPaint);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,192 @@
|
||||
package com.mapbox.mapboxgl.annotations;
|
||||
|
||||
import android.graphics.Point;
|
||||
import android.view.View;
|
||||
import com.mapbox.mapboxgl.geometry.LatLng;
|
||||
import com.mapbox.mapboxgl.views.R;
|
||||
|
||||
public class Marker extends Annotation {
|
||||
|
||||
float anchorU;
|
||||
float anchorV;
|
||||
boolean draggable;
|
||||
boolean flat;
|
||||
float infoWindowAnchorU;
|
||||
float infoWindowAnchorV;
|
||||
LatLng position;
|
||||
float rotation;
|
||||
String snippet;
|
||||
String sprite = "default_marker";
|
||||
String title;
|
||||
private InfoWindow infoWindow = null;
|
||||
|
||||
private boolean infoWindowShown = false;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public Marker() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* If two markers have the same LatLng, they are equal.
|
||||
*
|
||||
* @param other object
|
||||
* @return boolean - do they have the same LatLng
|
||||
*/
|
||||
public boolean equals(Object other) {
|
||||
if (!(other instanceof Marker)) return false;
|
||||
double lat = position.getLatitude();
|
||||
double lng = position.getLongitude();
|
||||
LatLng otherPosition = ((Marker)other).getPosition();
|
||||
double otherLat = otherPosition.getLatitude();
|
||||
double otherLng = otherPosition.getLongitude();
|
||||
return (lat == otherLat && otherLng == lng);
|
||||
}
|
||||
|
||||
public float getAlpha() {
|
||||
return alpha;
|
||||
}
|
||||
|
||||
public Point getAnchor() {
|
||||
return new Point((int)anchorU, (int)anchorV);
|
||||
}
|
||||
|
||||
public float getAnchorU() {
|
||||
return anchorU;
|
||||
}
|
||||
|
||||
public float getAnchorV() {
|
||||
return anchorV;
|
||||
}
|
||||
|
||||
public LatLng getPosition() {
|
||||
return position;
|
||||
}
|
||||
|
||||
public float getRotation() {
|
||||
return rotation;
|
||||
}
|
||||
|
||||
public String getSnippet() {
|
||||
return snippet;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void hideInfoWindow() {
|
||||
infoWindow.close();
|
||||
infoWindowShown = false;
|
||||
}
|
||||
|
||||
public boolean isDraggable() {
|
||||
return draggable;
|
||||
}
|
||||
|
||||
public boolean isFlat() {
|
||||
return flat;
|
||||
}
|
||||
|
||||
public boolean isInfoWindowShown () {
|
||||
return infoWindowShown;
|
||||
}
|
||||
|
||||
public void setAnchor(float u, float v) {
|
||||
this.anchorU = u;
|
||||
this.anchorV = v;
|
||||
}
|
||||
|
||||
public void setDraggable(boolean draggable) {
|
||||
this.draggable = draggable;
|
||||
}
|
||||
|
||||
public void setFlat(boolean flat) {
|
||||
this.flat = flat;
|
||||
}
|
||||
|
||||
public void setInfoWindowAnchor(float u, float v) {
|
||||
infoWindowAnchorU = u;
|
||||
infoWindowAnchorV = v;
|
||||
}
|
||||
|
||||
public void setPosition(LatLng latlng) {
|
||||
this.position = position;
|
||||
}
|
||||
|
||||
public void setRotation(float rotation) {
|
||||
this.rotation = rotation;
|
||||
}
|
||||
|
||||
public void setSnippet(String snippet) {
|
||||
this.snippet = snippet;
|
||||
}
|
||||
|
||||
/**
|
||||
* You can specify the name of a sprite to get a marker other than the default marker.
|
||||
* This name can be found in the sprite json file:
|
||||
*
|
||||
* https://github.com/mapbox/mapbox-gl-styles/blob/mb-pages/sprites/mapbox-streets.json
|
||||
*
|
||||
* @param sprite
|
||||
*/
|
||||
public void setSprite(String sprite) {
|
||||
this.sprite = sprite;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public void showInfoWindow() {
|
||||
|
||||
if (!isVisible() || mapView == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
getInfoWindow().open(this, getPosition(), (int) anchorU, (int) anchorV);
|
||||
getInfoWindow().setBoundMarker(this);
|
||||
infoWindowShown = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Use to set a custom OnTouchListener for the InfoWindow.
|
||||
* By default the InfoWindow will close on touch.
|
||||
* @param listener Custom OnTouchListener
|
||||
*/
|
||||
public void setInfoWindowOnTouchListener(View.OnTouchListener listener) {
|
||||
if (listener == null) {
|
||||
return;
|
||||
}
|
||||
getInfoWindow().setOnTouchListener(listener);
|
||||
}
|
||||
|
||||
/**
|
||||
* Common internal InfoWindow initialization method
|
||||
* @return InfoWindow for Marker
|
||||
*/
|
||||
private InfoWindow getInfoWindow() {
|
||||
if (infoWindow == null) {
|
||||
infoWindow = new InfoWindow(R.layout.infowindow, mapView);
|
||||
}
|
||||
return infoWindow;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setVisible(boolean visible) {
|
||||
super.setVisible(visible);
|
||||
if (!visible && infoWindowShown) {
|
||||
hideInfoWindow();
|
||||
}
|
||||
}
|
||||
|
||||
// TODO Method in Google Maps Android API
|
||||
// public int hashCode()
|
||||
|
||||
// TODO: Implement this method of Google Maps Android API
|
||||
// void setIcon(BitmapDescriptor icon) {
|
||||
//
|
||||
// }
|
||||
}
|
||||
@@ -0,0 +1,125 @@
|
||||
package com.mapbox.mapboxgl.annotations;
|
||||
|
||||
import com.mapbox.mapboxgl.geometry.LatLng;
|
||||
|
||||
public class MarkerOptions extends AnnotationOptions {
|
||||
|
||||
public MarkerOptions() {
|
||||
annotation = new Marker();
|
||||
}
|
||||
|
||||
public MarkerOptions anchor(float u, float v) {
|
||||
((Marker)annotation).anchorU = u;
|
||||
((Marker)annotation).anchorV = v;
|
||||
return this;
|
||||
}
|
||||
|
||||
public MarkerOptions draggable(boolean draggable) {
|
||||
((Marker)annotation).draggable = draggable;
|
||||
return this;
|
||||
}
|
||||
|
||||
public MarkerOptions flat(boolean flat) {
|
||||
((Marker)annotation).flat = flat;
|
||||
return this;
|
||||
}
|
||||
|
||||
public float getAnchorU() {
|
||||
return ((Marker)annotation).anchorU;
|
||||
}
|
||||
|
||||
public float getAnchorV() {
|
||||
return ((Marker)annotation).anchorV;
|
||||
}
|
||||
|
||||
// TODO: Implement this method of Google Maps Android API
|
||||
// public BitmapDescriptor getIcon () {
|
||||
//
|
||||
// }
|
||||
|
||||
public float getInfoWindowAnchorU() {
|
||||
return ((Marker)annotation).infoWindowAnchorU;
|
||||
}
|
||||
|
||||
public float getInfoWindowAnchorV() {
|
||||
return ((Marker)annotation).infoWindowAnchorV;
|
||||
}
|
||||
|
||||
public Marker getMarker() {
|
||||
return (Marker)annotation;
|
||||
}
|
||||
|
||||
public LatLng getPosition() {
|
||||
return ((Marker)annotation).position;
|
||||
}
|
||||
|
||||
public float getRotation() {
|
||||
return ((Marker)annotation).rotation;
|
||||
}
|
||||
|
||||
public String getSnippet() {
|
||||
return ((Marker)annotation).snippet;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return ((Marker)annotation).title;
|
||||
}
|
||||
|
||||
public MarkerOptions infoWindowAnchor(float u, float v) {
|
||||
((Marker)annotation).infoWindowAnchorU = u;
|
||||
((Marker)annotation).infoWindowAnchorV = v;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isDraggable() {
|
||||
return ((Marker)annotation).draggable;
|
||||
}
|
||||
|
||||
public boolean isFlat() {
|
||||
return ((Marker)annotation).flat;
|
||||
}
|
||||
|
||||
public boolean isVisible() {
|
||||
return ((Marker)annotation).visible;
|
||||
}
|
||||
|
||||
public MarkerOptions position(LatLng position) {
|
||||
((Marker)annotation).position = position;
|
||||
return this;
|
||||
}
|
||||
|
||||
public MarkerOptions rotation(float rotation) {
|
||||
((Marker)annotation).rotation = rotation;
|
||||
return this;
|
||||
}
|
||||
|
||||
public MarkerOptions snippet(String snippet) {
|
||||
((Marker)annotation).snippet = snippet;
|
||||
return this;
|
||||
}
|
||||
|
||||
public MarkerOptions sprite(String sprite) {
|
||||
((Marker)annotation).sprite = sprite;
|
||||
return this;
|
||||
}
|
||||
|
||||
public MarkerOptions title(String title) {
|
||||
((Marker)annotation).title = title;
|
||||
return this;
|
||||
}
|
||||
|
||||
public MarkerOptions visible(boolean visible) {
|
||||
annotation.visible = visible;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
// TODO: Implement this method of Google Maps Android API
|
||||
// public MarkerOptions icon(BitmapDescriptor icon) {
|
||||
//
|
||||
// }
|
||||
|
||||
// TODO: Implement this method of Google Maps Android API
|
||||
// public void writeToParcel (Parcel out, int flags)
|
||||
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package com.mapbox.mapboxgl.annotations;
|
||||
|
||||
import com.mapbox.mapboxgl.geometry.LatLng;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public abstract class MultiPoint extends Annotation {
|
||||
|
||||
List<LatLng> points;
|
||||
|
||||
public MultiPoint() {
|
||||
super();
|
||||
points = new ArrayList<>();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a copy of the points.
|
||||
*
|
||||
* @return points - as a copy
|
||||
*/
|
||||
public List<LatLng> getPoints() {
|
||||
return new ArrayList<>(points);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the points of this polyline. This method will take a copy
|
||||
* of the points, so further mutations to points will have no effect
|
||||
* on this polyline.
|
||||
*
|
||||
* @param points
|
||||
*/
|
||||
void setPoints(List<LatLng> points) {
|
||||
this.points = new ArrayList<>(points);
|
||||
}
|
||||
|
||||
|
||||
// TODO: Implement hashCode of Google Maps Android API
|
||||
// public int hashCode() {
|
||||
//
|
||||
// }
|
||||
|
||||
// TODO: Implement isGeodesic of Google Maps Android API
|
||||
// public boolean isGeodesic() {
|
||||
//
|
||||
// }
|
||||
|
||||
// TODO: Implement setGeodesic of Google Maps Android API
|
||||
// public void setGeodesic(boolean geodesic) {
|
||||
//
|
||||
// }
|
||||
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.mapbox.mapboxgl.annotations;
|
||||
|
||||
import com.mapbox.mapboxgl.geometry.LatLng;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public abstract class MultiPointOptions extends AnnotationOptions {
|
||||
|
||||
public MultiPointOptions() {}
|
||||
|
||||
public List<LatLng> getPoints() {
|
||||
// the getter gives us a copy, which is the safe thing to do...
|
||||
return ((MultiPoint)annotation).getPoints();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
package com.mapbox.mapboxgl.annotations;
|
||||
|
||||
|
||||
import android.graphics.Color;
|
||||
|
||||
import com.mapbox.mapboxgl.geometry.LatLng;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Polygon extends MultiPoint {
|
||||
|
||||
int fillColor = Color.BLACK; // default fillColor is black
|
||||
float strokeAlpha = 1;
|
||||
int strokeColor = Color.BLACK; // default strokeColor is black
|
||||
float strokeWidth = 10; // As specified by Google API Docs (in pixels)
|
||||
|
||||
List<List<LatLng>> holes;
|
||||
|
||||
public Polygon() {
|
||||
super();
|
||||
holes = new ArrayList<>();
|
||||
}
|
||||
|
||||
public int getFillColor() {
|
||||
return fillColor;
|
||||
}
|
||||
|
||||
public List<List<LatLng>> getHoles () {
|
||||
return holes;
|
||||
}
|
||||
|
||||
public int getStrokeColor() {
|
||||
return strokeColor;
|
||||
}
|
||||
|
||||
/**
|
||||
* UNIMPLEMENTED: Needs implementation in Native.
|
||||
* https://github.com/mapbox/mapbox-gl-native/issues/1737
|
||||
* @return stroke width as float
|
||||
*/
|
||||
public float getStrokeWidth() {
|
||||
return strokeWidth;
|
||||
}
|
||||
|
||||
public void setFillAlpha(float alpha) {
|
||||
this.alpha = alpha;
|
||||
}
|
||||
|
||||
public void setFillColor(int color) {
|
||||
fillColor = color;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the holes of this polygon. This method will take a copy of the holes,
|
||||
* so further mutations to holes parameter will have no effect on this polygon.
|
||||
*
|
||||
* @param holes
|
||||
*/
|
||||
public void setHoles(List<? extends List<LatLng>> holes) {
|
||||
this.holes = new ArrayList<>();
|
||||
for (List<LatLng> hole : holes) {
|
||||
this.holes.add(new ArrayList<>(hole));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the alpha (opacity) of the stroke
|
||||
*
|
||||
* UNIMPLEMENTED: Needs implementation in Native.
|
||||
*/
|
||||
public void setStrokeAlpha(float alpha) {
|
||||
strokeAlpha = alpha;
|
||||
}
|
||||
|
||||
public void setStrokeColor(int color) {
|
||||
strokeColor = color;
|
||||
}
|
||||
|
||||
/**
|
||||
* UNIMPLEMENTED: Needs implementation in Native.
|
||||
* https://github.com/mapbox/mapbox-gl-native/issues/1737
|
||||
* @return stroke width as float
|
||||
*/
|
||||
public void setStrokeWidth(float width) {
|
||||
strokeWidth = width;
|
||||
}
|
||||
|
||||
|
||||
// TODO: Implement equals of Google Maps Android API
|
||||
// public boolean equals (Object other) {
|
||||
//
|
||||
// }
|
||||
|
||||
// TODO: Implement hashCode of Google Maps Android API
|
||||
// public int hashCode () {
|
||||
//
|
||||
// }
|
||||
}
|
||||
@@ -0,0 +1,125 @@
|
||||
package com.mapbox.mapboxgl.annotations;
|
||||
|
||||
|
||||
import com.mapbox.mapboxgl.geometry.LatLng;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class PolygonOptions extends MultiPointOptions {
|
||||
|
||||
public PolygonOptions() {
|
||||
annotation = new Polygon();
|
||||
}
|
||||
|
||||
public PolygonOptions add(LatLng point) {
|
||||
((MultiPoint)annotation).points.add(point);
|
||||
return this;
|
||||
}
|
||||
|
||||
public PolygonOptions add(LatLng... points) {
|
||||
for (LatLng point : points) {
|
||||
add(point);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public PolygonOptions addAll(Iterable<LatLng> points) {
|
||||
for (LatLng point : points) {
|
||||
add(point);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* UNIMPLEMENTED: Needs implementation in Native.
|
||||
* https://github.com/mapbox/mapbox-gl-native/issues/1729
|
||||
*
|
||||
* @param points - an iterable (list) of points for cutting a hole
|
||||
* @return PolygonOptions - the options object
|
||||
*/
|
||||
public PolygonOptions addHole (Iterable<LatLng> points) {
|
||||
List<LatLng> hole = new ArrayList<>();
|
||||
for (LatLng point : points) {
|
||||
hole.add(point);
|
||||
}
|
||||
((Polygon)annotation).holes.add(hole);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the color of the polygon.
|
||||
*
|
||||
* @param color - the color in ARGB format
|
||||
* @return PolygonOptions - the options object
|
||||
*/
|
||||
public PolygonOptions fillColor(int color) {
|
||||
((Polygon)annotation).fillColor = color;
|
||||
return this;
|
||||
}
|
||||
|
||||
public int getFillColor() {
|
||||
return ((Polygon)annotation).fillColor;
|
||||
}
|
||||
|
||||
/**
|
||||
* UNIMPLEMENTED: Needs implementation in Native.
|
||||
* https://github.com/mapbox/mapbox-gl-native/issues/1729
|
||||
*
|
||||
* @return a list of lists of points for cutting holes
|
||||
*/
|
||||
public List<List<LatLng>> getHoles() {
|
||||
return ((Polygon)annotation).holes;
|
||||
}
|
||||
|
||||
public Polygon getPolygon() {
|
||||
return ((Polygon)annotation);
|
||||
}
|
||||
|
||||
public int getStrokeColor() {
|
||||
return ((Polygon)annotation).strokeColor;
|
||||
}
|
||||
|
||||
/**
|
||||
* UNIMPLEMENTED: Needs implementation in Native.
|
||||
* https://github.com/mapbox/mapbox-gl-native/issues/1737
|
||||
*
|
||||
* @return stroke width as float
|
||||
*/
|
||||
public float getStrokeWidth() {
|
||||
return ((Polygon)annotation).strokeWidth;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the color of the stroke of the polygon.
|
||||
*
|
||||
* @param color - the color in ARGB format
|
||||
* @return PolygonOptions - the options object
|
||||
*/
|
||||
public PolygonOptions strokeColor(int color) {
|
||||
((Polygon)annotation).strokeColor = color;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* UNIMPLEMENTED: Needs implementation in Native.
|
||||
* https://github.com/mapbox/mapbox-gl-native/issues/1737
|
||||
*
|
||||
* @return stroke width as float
|
||||
*/
|
||||
public PolygonOptions strokeWidth(float width) {
|
||||
((Polygon)annotation).strokeWidth = width;
|
||||
return this;
|
||||
}
|
||||
|
||||
public PolygonOptions visible(boolean visible) {
|
||||
annotation.visible = visible;
|
||||
return this;
|
||||
}
|
||||
|
||||
// TODO: Implement writeToParcel of Google Maps Android API
|
||||
// public void writeToParcel(Parcel out, int flags) {
|
||||
//
|
||||
// }
|
||||
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package com.mapbox.mapboxgl.annotations;
|
||||
|
||||
import android.graphics.Color;
|
||||
|
||||
import com.mapbox.mapboxgl.geometry.LatLng;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class Polyline extends MultiPoint {
|
||||
|
||||
int color = Color.BLACK; // default color is black
|
||||
float width = 10; // As specified by Google API Docs (in pixels)
|
||||
|
||||
public Polyline() {
|
||||
super();
|
||||
}
|
||||
|
||||
public int getColor() {
|
||||
return color;
|
||||
}
|
||||
|
||||
public float getWidth() {
|
||||
return width;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets the color of the polyline.
|
||||
*
|
||||
* @param color - the color in ARGB format
|
||||
*/
|
||||
public void setColor(int color) {
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets the width of the polyline.
|
||||
*
|
||||
* @param width in pixels
|
||||
* @return
|
||||
*/
|
||||
public void setWidth(float width) {
|
||||
this.width = width;
|
||||
}
|
||||
|
||||
// TODO: Implement equals of Google Maps Android API
|
||||
// public boolean equals(Object other) {
|
||||
//
|
||||
// }
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
package com.mapbox.mapboxgl.annotations;
|
||||
|
||||
import com.mapbox.mapboxgl.geometry.LatLng;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class PolylineOptions extends MultiPointOptions {
|
||||
|
||||
public PolylineOptions() {
|
||||
annotation = new Polyline();
|
||||
}
|
||||
|
||||
public PolylineOptions add(LatLng point) {
|
||||
((MultiPoint)annotation).points.add(point);
|
||||
return this;
|
||||
}
|
||||
|
||||
public PolylineOptions add(LatLng... points) {
|
||||
for (LatLng point : points) {
|
||||
add(point);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public PolylineOptions addAll(Iterable<LatLng> points) {
|
||||
for (LatLng point : points) {
|
||||
add(point);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the color of the polyline.
|
||||
*
|
||||
* @param color - the color in ARGB format
|
||||
*/
|
||||
public PolylineOptions color(int color) {
|
||||
((Polyline)annotation).color = color;
|
||||
return this;
|
||||
}
|
||||
|
||||
public int getColor() {
|
||||
return ((Polyline)annotation).color;
|
||||
}
|
||||
|
||||
public Polyline getPolyline() {
|
||||
return ((Polyline)annotation);
|
||||
}
|
||||
|
||||
public float getWidth() {
|
||||
return ((Polyline)annotation).width;
|
||||
}
|
||||
|
||||
public PolylineOptions visible(boolean visible) {
|
||||
annotation.visible = visible;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the width of the polyline.
|
||||
*
|
||||
* @param width in pixels
|
||||
* @return
|
||||
*/
|
||||
public PolylineOptions width(float width) {
|
||||
((Polyline)annotation).width = width;
|
||||
return this;
|
||||
}
|
||||
|
||||
// TODO: Implement writeToParcel of Google Maps Android API
|
||||
// public void writeToParcel(Parcel out, int flags) {
|
||||
//
|
||||
// }
|
||||
|
||||
}
|
||||
@@ -119,15 +119,7 @@ public final class BoundingBox implements Parcelable, Serializable {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new StringBuffer().append("N:")
|
||||
.append(this.mLatNorth)
|
||||
.append("; E:")
|
||||
.append(this.mLonEast)
|
||||
.append("; S:")
|
||||
.append(this.mLatSouth)
|
||||
.append("; W:")
|
||||
.append(this.mLonWest)
|
||||
.toString();
|
||||
return "N:" + this.mLatNorth + "; E:" + this.mLonEast + "; S:" + this.mLatSouth + "; W:" + this.mLonWest;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -164,17 +156,8 @@ public final class BoundingBox implements Parcelable, Serializable {
|
||||
*/
|
||||
public boolean equals(final BoundingBox other) {
|
||||
|
||||
if (other == null) {
|
||||
return false;
|
||||
}
|
||||
if (other == this) {
|
||||
return true;
|
||||
}
|
||||
return other != null && (other == this || mLatNorth == other.getLatNorth() && mLatSouth == other.getLatSouth() && mLonEast == other.getLonEast() && mLonWest == other.getLonWest());
|
||||
|
||||
return mLatNorth == other.getLatNorth()
|
||||
&& mLatSouth == other.getLatSouth()
|
||||
&& mLonEast == other.getLonEast()
|
||||
&& mLonWest == other.getLonWest();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -97,18 +97,8 @@ public class LatLng implements ILatLng, Parcelable, Serializable {
|
||||
|
||||
LatLng latLng = (LatLng) o;
|
||||
|
||||
if (Double.compare(latLng.altitude, altitude) != 0) {
|
||||
return false;
|
||||
}
|
||||
return Double.compare(latLng.altitude, altitude) == 0 && Double.compare(latLng.latitude, latitude) == 0 && Double.compare(latLng.longitude, longitude) == 0;
|
||||
|
||||
if (Double.compare(latLng.latitude, latitude) != 0) {
|
||||
return false;
|
||||
}
|
||||
if (Double.compare(latLng.longitude, longitude) != 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -56,11 +56,8 @@ public class LatLngZoom extends LatLng implements Parcelable, Serializable {
|
||||
|
||||
LatLngZoom that = (LatLngZoom) o;
|
||||
|
||||
if (Double.compare(that.zoom, zoom) != 0) {
|
||||
return false;
|
||||
}
|
||||
return Double.compare(that.zoom, zoom) == 0;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -56,14 +56,8 @@ public class ProjectedMeters implements IProjectedMeters, Parcelable, Serializab
|
||||
|
||||
ProjectedMeters projectedMeters = (ProjectedMeters) o;
|
||||
|
||||
if (Double.compare(projectedMeters.easting, easting) != 0) {
|
||||
return false;
|
||||
}
|
||||
if (Double.compare(projectedMeters.northing, northing) != 0) {
|
||||
return false;
|
||||
}
|
||||
return Double.compare(projectedMeters.easting, easting) == 0 && Double.compare(projectedMeters.northing, northing) == 0;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,100 @@
|
||||
package com.mapbox.mapboxgl.http;
|
||||
|
||||
import com.mapbox.mapboxgl.constants.MapboxConstants;
|
||||
import com.squareup.okhttp.Call;
|
||||
import com.squareup.okhttp.Callback;
|
||||
import com.squareup.okhttp.OkHttpClient;
|
||||
import com.squareup.okhttp.Request;
|
||||
import com.squareup.okhttp.Response;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InterruptedIOException;
|
||||
import java.net.ProtocolException;
|
||||
import java.net.SocketException;
|
||||
import java.net.UnknownHostException;
|
||||
|
||||
import javax.net.ssl.SSLException;
|
||||
|
||||
class HTTPContext {
|
||||
|
||||
private static final int CONNECTION_ERROR = 0;
|
||||
private static final int TEMPORARY_ERROR = 1;
|
||||
private static final int PERMANENT_ERROR = 2;
|
||||
|
||||
private static HTTPContext mInstance = null;
|
||||
|
||||
private OkHttpClient mClient;
|
||||
|
||||
private HTTPContext() {
|
||||
super();
|
||||
mClient = new OkHttpClient();
|
||||
}
|
||||
|
||||
public static HTTPContext getInstance() {
|
||||
if (mInstance == null) {
|
||||
mInstance = new HTTPContext();
|
||||
}
|
||||
|
||||
return mInstance;
|
||||
}
|
||||
|
||||
public HTTPRequest createRequest(long nativePtr, String resourceUrl, String userAgent, String etag, String modified) {
|
||||
return new HTTPRequest(nativePtr, resourceUrl, userAgent, etag, modified);
|
||||
}
|
||||
|
||||
public class HTTPRequest implements Callback {
|
||||
private long mNativePtr = 0;
|
||||
|
||||
private Call mCall;
|
||||
private Request mRequest;
|
||||
|
||||
private native void nativeOnFailure(long nativePtr, int type, String message);
|
||||
private native void nativeOnResponse(long nativePtr, int code, String message, String etag, String modified, String cacheControl, String expires, byte[] body);
|
||||
|
||||
private HTTPRequest(long nativePtr, String resourceUrl, String userAgent, String etag, String modified) {
|
||||
mNativePtr = nativePtr;
|
||||
Request.Builder builder = new Request.Builder().url(resourceUrl).tag(resourceUrl.toLowerCase(MapboxConstants.MAPBOX_LOCALE)).addHeader("User-Agent", userAgent);
|
||||
if (etag.length() > 0) {
|
||||
builder = builder.addHeader("If-None-Match", etag);
|
||||
} else if (modified.length() > 0) {
|
||||
builder = builder.addHeader("If-Modified-Since", modified);
|
||||
}
|
||||
mRequest = builder.build();
|
||||
}
|
||||
|
||||
public void start() {
|
||||
mCall = HTTPContext.getInstance().mClient.newCall(mRequest);
|
||||
mCall.enqueue(this);
|
||||
}
|
||||
|
||||
public void cancel() {
|
||||
mCall.cancel();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Request request, IOException e) {
|
||||
int type = PERMANENT_ERROR;
|
||||
if ((e instanceof UnknownHostException) || (e instanceof SocketException) || (e instanceof ProtocolException) || (e instanceof SSLException)) {
|
||||
type = CONNECTION_ERROR;
|
||||
} else if ((e instanceof InterruptedIOException)) {
|
||||
type = TEMPORARY_ERROR;
|
||||
}
|
||||
nativeOnFailure(mNativePtr, type, e.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResponse(Response response) throws IOException {
|
||||
byte[] body;
|
||||
try {
|
||||
body = response.body().bytes();
|
||||
} catch (IOException e) {
|
||||
onFailure(mRequest, e);
|
||||
return;
|
||||
} finally {
|
||||
response.body().close();
|
||||
}
|
||||
|
||||
nativeOnResponse(mNativePtr, response.code(), response.message(), response.header("ETag"), response.header("Last-Modified"), response.header("Cache-Control"), response.header("Expires"), body);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
package com.mapbox.mapboxgl.util;
|
||||
|
||||
import com.mapbox.mapboxgl.constants.MapboxConstants;
|
||||
import com.squareup.okhttp.Callback;
|
||||
import com.squareup.okhttp.OkHttpClient;
|
||||
import com.squareup.okhttp.Request;
|
||||
|
||||
public class JavaFileSource {
|
||||
|
||||
private static JavaFileSource instance = null;
|
||||
|
||||
// Single reference to OkHttp for performance gains
|
||||
private OkHttpClient client;
|
||||
|
||||
/**
|
||||
* Private Constructor to support Singleton pattern
|
||||
*/
|
||||
private JavaFileSource() {
|
||||
super();
|
||||
client = new OkHttpClient();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the singleton instance of JavaFileSource
|
||||
* @return Reference to the Singleton Instance of JavaFileSource
|
||||
*/
|
||||
public static JavaFileSource getInstance() {
|
||||
if (instance == null) {
|
||||
instance = new JavaFileSource();
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make an HTTP Request
|
||||
* @param resourceUrl URL to resource
|
||||
* @param callback Callback class
|
||||
*/
|
||||
public void request(final String resourceUrl, final Callback callback) {
|
||||
Request request = new Request.Builder().url(resourceUrl).tag(resourceUrl.toLowerCase(MapboxConstants.MAPBOX_LOCALE)).build();
|
||||
client.newCall(request).enqueue(callback);
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempt to cancel HTTP Request made
|
||||
* @param resourceUrl URL of request to cancel
|
||||
*/
|
||||
public void cancel(final String resourceUrl) {
|
||||
client.cancel(resourceUrl.toLowerCase(MapboxConstants.MAPBOX_LOCALE));
|
||||
}
|
||||
}
|
||||
@@ -2,12 +2,14 @@ package com.mapbox.mapboxgl.views;
|
||||
|
||||
import android.graphics.PointF;
|
||||
import android.view.Surface;
|
||||
import android.util.Log;
|
||||
|
||||
import com.mapbox.mapboxgl.annotations.Marker;
|
||||
import com.mapbox.mapboxgl.annotations.Polygon;
|
||||
import com.mapbox.mapboxgl.annotations.Polyline;
|
||||
import com.mapbox.mapboxgl.geometry.BoundingBox;
|
||||
import com.mapbox.mapboxgl.geometry.LatLng;
|
||||
import com.mapbox.mapboxgl.geometry.LatLngZoom;
|
||||
import com.mapbox.mapboxgl.geometry.ProjectedMeters;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
// Class that wraps the native methods for convenience
|
||||
@@ -39,11 +41,19 @@ class NativeMapView {
|
||||
// Constructors
|
||||
//
|
||||
|
||||
public NativeMapView(MapView mapView, String cachePath, String dataPath, String apkPath) {
|
||||
public NativeMapView(MapView mapView, String cachePath, String dataPath, String apkPath, float pixelRatio, int availableProcessors, long totalMemory) {
|
||||
if (availableProcessors < 0) {
|
||||
throw new IllegalArgumentException("availableProcessors cannot be negative.");
|
||||
}
|
||||
|
||||
if (totalMemory < 0) {
|
||||
throw new IllegalArgumentException("totalMemory cannot be negative.");
|
||||
}
|
||||
|
||||
mMapView = mapView;
|
||||
|
||||
// Create the NativeMapView
|
||||
mNativeMapViewPtr = nativeCreate(cachePath, dataPath, apkPath);
|
||||
mNativeMapViewPtr = nativeCreate(cachePath, dataPath, apkPath, pixelRatio, availableProcessors, totalMemory);
|
||||
}
|
||||
|
||||
//
|
||||
@@ -90,8 +100,7 @@ class NativeMapView {
|
||||
nativeOnInvalidate(mNativeMapViewPtr);
|
||||
}
|
||||
|
||||
public void resize(int width, int height, float ratio, int fbWidth,
|
||||
int fbHeight) {
|
||||
public void resizeView(int width, int height) {
|
||||
if (width < 0) {
|
||||
throw new IllegalArgumentException("width cannot be negative.");
|
||||
}
|
||||
@@ -100,6 +109,19 @@ class NativeMapView {
|
||||
throw new IllegalArgumentException("height cannot be negative.");
|
||||
}
|
||||
|
||||
if (width > 65535) {
|
||||
throw new IllegalArgumentException(
|
||||
"width cannot be greater than 65535.");
|
||||
}
|
||||
|
||||
if (height > 65535) {
|
||||
throw new IllegalArgumentException(
|
||||
"height cannot be greater than 65535.");
|
||||
}
|
||||
nativeViewResize(mNativeMapViewPtr, width, height);
|
||||
}
|
||||
|
||||
public void resizeFramebuffer(int fbWidth, int fbHeight) {
|
||||
if (fbWidth < 0) {
|
||||
throw new IllegalArgumentException("fbWidth cannot be negative.");
|
||||
}
|
||||
@@ -117,7 +139,7 @@ class NativeMapView {
|
||||
throw new IllegalArgumentException(
|
||||
"fbHeight cannot be greater than 65535.");
|
||||
}
|
||||
nativeResize(mNativeMapViewPtr, width, height, ratio, fbWidth, fbHeight);
|
||||
nativeFramebufferResize(mNativeMapViewPtr, fbWidth, fbHeight);
|
||||
}
|
||||
|
||||
public void addClass(String clazz) {
|
||||
@@ -151,7 +173,7 @@ class NativeMapView {
|
||||
public void setDefaultTransitionDuration(long milliseconds) {
|
||||
if (milliseconds < 0) {
|
||||
throw new IllegalArgumentException(
|
||||
"durationMilliseconds cannot be negative.");
|
||||
"milliseconds cannot be negative.");
|
||||
}
|
||||
|
||||
nativeSetDefaultTransitionDuration(mNativeMapViewPtr,
|
||||
@@ -163,7 +185,7 @@ class NativeMapView {
|
||||
}
|
||||
|
||||
public void setStyleJson(String newStyleJson) {
|
||||
setStyleJson(newStyleJson, "");
|
||||
setStyleJson(newStyleJson, "");
|
||||
}
|
||||
|
||||
public void setStyleJson(String newStyleJson, String base) {
|
||||
@@ -186,6 +208,10 @@ class NativeMapView {
|
||||
nativeCancelTransitions(mNativeMapViewPtr);
|
||||
}
|
||||
|
||||
public void setGestureInProgress(boolean inProgress) {
|
||||
nativeSetGestureInProgress(mNativeMapViewPtr, inProgress);
|
||||
}
|
||||
|
||||
public void moveBy(double dx, double dy) {
|
||||
moveBy(dx, dy, 0);
|
||||
}
|
||||
@@ -303,6 +329,42 @@ class NativeMapView {
|
||||
nativeResetNorth(mNativeMapViewPtr);
|
||||
}
|
||||
|
||||
public long addMarker(Marker marker) {
|
||||
return nativeAddMarker(mNativeMapViewPtr, marker);
|
||||
}
|
||||
|
||||
public long addPolyline(Polyline polyline) {
|
||||
return nativeAddPolyline(mNativeMapViewPtr, polyline);
|
||||
}
|
||||
|
||||
public long addPolygon(Polygon polygon) {
|
||||
return nativeAddPolygon(mNativeMapViewPtr, polygon);
|
||||
}
|
||||
|
||||
public long[] addPolygons(List<Polygon> polygon) {
|
||||
return nativeAddPolygons(mNativeMapViewPtr, polygon);
|
||||
}
|
||||
|
||||
public void removeAnnotation(long id) {
|
||||
nativeRemoveAnnotation(mNativeMapViewPtr, id);
|
||||
}
|
||||
|
||||
public void removeAnnotations(long[] ids) {
|
||||
nativeRemoveAnnotations(mNativeMapViewPtr, ids);
|
||||
}
|
||||
|
||||
public long[] getAnnotationsInBounds(BoundingBox bbox) {
|
||||
return nativeGetAnnotationsInBounds(mNativeMapViewPtr, bbox);
|
||||
}
|
||||
|
||||
public void setSprite(String symbol, int width, int height, float scale, byte[] pixels) {
|
||||
nativeSetSprite(mNativeMapViewPtr, symbol, width, height, scale, pixels);
|
||||
}
|
||||
|
||||
public void onLowMemory() {
|
||||
nativeOnLowMemory(mNativeMapViewPtr);
|
||||
}
|
||||
|
||||
public void setDebug(boolean debug) {
|
||||
nativeSetDebug(mNativeMapViewPtr, debug);
|
||||
}
|
||||
@@ -315,11 +377,27 @@ class NativeMapView {
|
||||
return nativeGetDebug(mNativeMapViewPtr);
|
||||
}
|
||||
|
||||
public void setCollisionDebug(boolean debug) {
|
||||
nativeSetCollisionDebug(mNativeMapViewPtr, debug);
|
||||
}
|
||||
|
||||
public void toggleCollisionDebug() {
|
||||
nativeToggleCollisionDebug(mNativeMapViewPtr);
|
||||
}
|
||||
|
||||
public boolean getCollisionDebug() {
|
||||
return nativeGetCollisionDebug(mNativeMapViewPtr);
|
||||
}
|
||||
|
||||
public boolean isFullyLoaded() {
|
||||
return nativeIsFullyLoaded(mNativeMapViewPtr);
|
||||
}
|
||||
|
||||
public void setReachability(boolean status) {
|
||||
nativeSetReachability(mNativeMapViewPtr, status);
|
||||
}
|
||||
|
||||
//public void getWorldBoundsMeters();
|
||||
//public void ();
|
||||
|
||||
//public void getWorldBoundsLatLng();
|
||||
|
||||
@@ -343,6 +421,10 @@ class NativeMapView {
|
||||
return nativeLatLngForPixel(mNativeMapViewPtr, pixel);
|
||||
}
|
||||
|
||||
public double getTopOffsetPixelsForAnnotationSymbol(String symbolName) {
|
||||
return nativeGetTopOffsetPixelsForAnnotationSymbol(mNativeMapViewPtr, symbolName);
|
||||
}
|
||||
|
||||
//
|
||||
// Callbacks
|
||||
//
|
||||
@@ -351,8 +433,8 @@ class NativeMapView {
|
||||
mMapView.onInvalidate();
|
||||
}
|
||||
|
||||
protected void onMapChanged() {
|
||||
mMapView.onMapChanged();
|
||||
protected void onMapChanged(int rawChange) {
|
||||
mMapView.onMapChanged(rawChange);
|
||||
}
|
||||
|
||||
protected void onFpsChanged(double fps) {
|
||||
@@ -370,7 +452,7 @@ class NativeMapView {
|
||||
super.finalize();
|
||||
}
|
||||
|
||||
private native long nativeCreate(String cachePath, String dataPath, String apkPath);
|
||||
private native long nativeCreate(String cachePath, String dataPath, String apkPath, float pixelRatio, int availableProcessors, long totalMemory);
|
||||
|
||||
private native void nativeDestroy(long nativeMapViewPtr);
|
||||
|
||||
@@ -395,8 +477,9 @@ class NativeMapView {
|
||||
|
||||
private native void nativeOnInvalidate(long nativeMapViewPtr);
|
||||
|
||||
private native void nativeResize(long nativeMapViewPtr, int width,
|
||||
int height, float ratio, int fbWidth, int fbHeight);
|
||||
private native void nativeViewResize(long nativeMapViewPtr, int width, int height);
|
||||
|
||||
private native void nativeFramebufferResize(long nativeMapViewPtr, int fbWidth, int fbHeight);
|
||||
|
||||
private native void nativeAddClass(long nativeMapViewPtr, String clazz);
|
||||
|
||||
@@ -427,6 +510,8 @@ class NativeMapView {
|
||||
|
||||
private native void nativeCancelTransitions(long nativeMapViewPtr);
|
||||
|
||||
private native void nativeSetGestureInProgress(long nativeMapViewPtr, boolean inProgress);
|
||||
|
||||
private native void nativeMoveBy(long nativeMapViewPtr, double dx,
|
||||
double dy, long duration);
|
||||
|
||||
@@ -474,12 +559,39 @@ class NativeMapView {
|
||||
|
||||
private native void nativeResetNorth(long nativeMapViewPtr);
|
||||
|
||||
private native long nativeAddMarker(long nativeMapViewPtr, Marker marker);
|
||||
|
||||
private native long nativeAddPolyline(long nativeMapViewPtr, Polyline polyline);
|
||||
|
||||
private native long nativeAddPolygon(long mNativeMapViewPtr, Polygon polygon);
|
||||
|
||||
private native long[] nativeAddPolygons(long mNativeMapViewPtr, List<Polygon> polygon);
|
||||
|
||||
private native void nativeRemoveAnnotation(long nativeMapViewPtr, long id);
|
||||
|
||||
private native void nativeRemoveAnnotations(long nativeMapViewPtr, long[] id);
|
||||
|
||||
private native long[] nativeGetAnnotationsInBounds(long mNativeMapViewPtr, BoundingBox bbox);
|
||||
|
||||
private native void nativeSetSprite(long nativeMapViewPtr, String symbol,
|
||||
int width, int height, float scale, byte[] pixels);
|
||||
|
||||
private native void nativeOnLowMemory(long nativeMapViewPtr);
|
||||
|
||||
private native void nativeSetDebug(long nativeMapViewPtr, boolean debug);
|
||||
|
||||
private native void nativeToggleDebug(long nativeMapViewPtr);
|
||||
|
||||
private native boolean nativeGetDebug(long nativeMapViewPtr);
|
||||
|
||||
private native void nativeSetCollisionDebug(long nativeMapViewPtr, boolean debug);
|
||||
|
||||
private native void nativeToggleCollisionDebug(long nativeMapViewPtr);
|
||||
|
||||
private native boolean nativeGetCollisionDebug(long nativeMapViewPtr);
|
||||
|
||||
private native boolean nativeIsFullyLoaded(long nativeMapViewPtr);
|
||||
|
||||
private native void nativeSetReachability(long nativeMapViewPtr, boolean status);
|
||||
|
||||
//private native void nativeGetWorldBoundsMeters(long nativeMapViewPtr);
|
||||
@@ -495,4 +607,6 @@ class NativeMapView {
|
||||
private native PointF nativePixelForLatLng(long nativeMapViewPtr, LatLng latLng);
|
||||
|
||||
private native LatLng nativeLatLngForPixel(long nativeMapViewPtr, PointF pixel);
|
||||
|
||||
private native double nativeGetTopOffsetPixelsForAnnotationSymbol(long nativeMapViewPtr, String symbolName);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
|
||||
<item
|
||||
android:color="?attr/colorPrimaryDark"
|
||||
android:state_pressed="true"/>
|
||||
<item
|
||||
android:color="?attr/colorPrimary" />
|
||||
</selector>
|
||||
|
After Width: | Height: | Size: 3.7 KiB |
|
After Width: | Height: | Size: 2.1 KiB |
|
After Width: | Height: | Size: 2.1 KiB |
|
Before Width: | Height: | Size: 4.7 KiB After Width: | Height: | Size: 4.7 KiB |
|
Before Width: | Height: | Size: 4.0 KiB After Width: | Height: | Size: 4.0 KiB |
|
After Width: | Height: | Size: 2.4 KiB |
|
After Width: | Height: | Size: 1.3 KiB |
|
After Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 4.3 KiB After Width: | Height: | Size: 4.3 KiB |
|
After Width: | Height: | Size: 4.7 KiB |
|
After Width: | Height: | Size: 2.6 KiB |
|
After Width: | Height: | Size: 2.7 KiB |
|
Before Width: | Height: | Size: 5.6 KiB After Width: | Height: | Size: 5.6 KiB |
|
After Width: | Height: | Size: 7.4 KiB |
|
After Width: | Height: | Size: 4.2 KiB |
|
After Width: | Height: | Size: 4.1 KiB |
|
After Width: | Height: | Size: 6.9 KiB |
|
Before Width: | Height: | Size: 7.0 KiB After Width: | Height: | Size: 7.0 KiB |
|
After Width: | Height: | Size: 730 B |
|
After Width: | Height: | Size: 836 B |
|
Before Width: | Height: | Size: 8.6 KiB After Width: | Height: | Size: 8.6 KiB |
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:state_pressed="true" android:drawable="@drawable/ic_info_blue_pressed" />
|
||||
<item android:drawable="@drawable/ic_info_blue_normal" />
|
||||
</selector>
|
||||
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@android:id/text1"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="?android:attr/textAppearanceListItemSmall"
|
||||
android:textColor="@android:color/white"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingLeft="16dp"
|
||||
android:paddingRight="16dp"
|
||||
android:minHeight="?android:attr/listPreferredItemHeightSmall" />
|
||||
@@ -0,0 +1,52 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:background="@color/white"
|
||||
android:padding="5dp"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/infowindow_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="0dp"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="18sp"
|
||||
android:maxEms="17"
|
||||
android:layout_gravity="left"
|
||||
android:layout_weight="1"
|
||||
android:text="@string/infoWindowTitle"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/infowindow_description"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="14sp"
|
||||
android:maxEms="17"
|
||||
android:text="@string/infoWindowDescription"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/infowindow_subdescription"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="12sp"
|
||||
android:maxEms="17"
|
||||
android:text="@string/infoWindowAddress"
|
||||
android:visibility="gone"/>
|
||||
</LinearLayout>
|
||||
|
||||
<com.mapbox.mapboxgl.annotations.InfoWindowTipView
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="10dp"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<array name="attribution_names">
|
||||
<item>© Mapbox</item>
|
||||
<item>© OpenStreetMap</item>
|
||||
<item>Improve this map</item>
|
||||
</array>
|
||||
<array name="attribution_links" formatted="false" translatable="false">
|
||||
<item>https://www.mapbox.com/about/maps/</item>
|
||||
<item>http://www.openstreetmap.org/about/</item>
|
||||
<item>https://www.mapbox.com/map-feedback/#/%1$f/%2$f/%3$d</item>
|
||||
</array>
|
||||
</resources>
|
||||
@@ -1,23 +1,77 @@
|
||||
<resources>
|
||||
<attr name="centerLongitude" format="float" />
|
||||
<attr name="centerLatitude" format="float" />
|
||||
<attr name="zoomLevel" format="float" />
|
||||
<attr name="direction" format="float" />
|
||||
<attr name="zoomEnabled" format="boolean" />
|
||||
<attr name="scrollEnabled" format="boolean" />
|
||||
<attr name="rotateEnabled" format="boolean" />
|
||||
<attr name="debugActive" format="boolean" />
|
||||
<attr name="styleUrl" format="string" />
|
||||
|
||||
<declare-styleable name="MapView">
|
||||
<attr name="centerLongitude" />
|
||||
<attr name="centerLatitude" />
|
||||
<attr name="zoomLevel" />
|
||||
<attr name="direction" />
|
||||
<attr name="zoomEnabled" />
|
||||
<attr name="scrollEnabled" />
|
||||
<attr name="rotateEnabled" />
|
||||
<attr name="debugActive" />
|
||||
<attr name="styleUrl" />
|
||||
<attr name="centerLongitude" format="float" />
|
||||
<attr name="centerLatitude" format="float" />
|
||||
<attr name="zoomLevel" format="float" />
|
||||
<attr name="direction" format="float" />
|
||||
<attr name="zoomEnabled" format="boolean" />
|
||||
<attr name="scrollEnabled" format="boolean" />
|
||||
<attr name="rotateEnabled" format="boolean" />
|
||||
<attr name="debugActive" format="boolean" />
|
||||
<attr name="styleUrl" format="string" />
|
||||
<attr name="accessToken" format="string"/>
|
||||
<attr name="styleClasses" format="string"/>
|
||||
<attr name="myLocationEnabled" format="boolean" />
|
||||
<attr name="compassEnabled" format="boolean" />
|
||||
<attr name="compassGravity">
|
||||
<flag name="top" value="0x30" />
|
||||
<flag name="bottom" value="0x50" />
|
||||
<flag name="left" value="0x03" />
|
||||
<flag name="right" value="0x05" />
|
||||
<flag name="center_vertical" value="0x10" />
|
||||
<flag name="fill_vertical" value="0x70" />
|
||||
<flag name="center_horizontal" value="0x01" />
|
||||
<flag name="fill_horizontal" value="0x07" />
|
||||
<flag name="center" value="0x11" />
|
||||
<flag name="fill" value="0x77" />
|
||||
<flag name="clip_vertical" value="0x80" />
|
||||
<flag name="clip_horizontal" value="0x08" />
|
||||
<flag name="start" value="0x00800003" />
|
||||
<flag name="end" value="0x00800005" />
|
||||
</attr>
|
||||
<attr name="compassMarginLeft" format="dimension"/>
|
||||
<attr name="compassMarginTop" format="dimension"/>
|
||||
<attr name="compassMarginRight" format="dimension"/>
|
||||
<attr name="compassMarginBottom" format="dimension"/>
|
||||
<attr name="logoGravity">
|
||||
<flag name="top" value="0x30" />
|
||||
<flag name="bottom" value="0x50" />
|
||||
<flag name="left" value="0x03" />
|
||||
<flag name="right" value="0x05" />
|
||||
<flag name="center_vertical" value="0x10" />
|
||||
<flag name="fill_vertical" value="0x70" />
|
||||
<flag name="center_horizontal" value="0x01" />
|
||||
<flag name="fill_horizontal" value="0x07" />
|
||||
<flag name="center" value="0x11" />
|
||||
<flag name="fill" value="0x77" />
|
||||
<flag name="clip_vertical" value="0x80" />
|
||||
<flag name="clip_horizontal" value="0x08" />
|
||||
<flag name="start" value="0x00800003" />
|
||||
<flag name="end" value="0x00800005" />
|
||||
</attr>
|
||||
<attr name="logoMarginLeft" format="dimension"/>
|
||||
<attr name="logoMarginTop" format="dimension"/>
|
||||
<attr name="logoMarginRight" format="dimension"/>
|
||||
<attr name="logoMarginBottom" format="dimension"/>
|
||||
<attr name="attributionGravity">
|
||||
<flag name="top" value="0x30" />
|
||||
<flag name="bottom" value="0x50" />
|
||||
<flag name="left" value="0x03" />
|
||||
<flag name="right" value="0x05" />
|
||||
<flag name="center_vertical" value="0x10" />
|
||||
<flag name="fill_vertical" value="0x70" />
|
||||
<flag name="center_horizontal" value="0x01" />
|
||||
<flag name="fill_horizontal" value="0x07" />
|
||||
<flag name="center" value="0x11" />
|
||||
<flag name="fill" value="0x77" />
|
||||
<flag name="clip_vertical" value="0x80" />
|
||||
<flag name="clip_horizontal" value="0x08" />
|
||||
<flag name="start" value="0x00800003" />
|
||||
<flag name="end" value="0x00800005" />
|
||||
</attr>
|
||||
<attr name="attributionMarginLeft" format="dimension"/>
|
||||
<attr name="attributionMarginTop" format="dimension"/>
|
||||
<attr name="attributionMarginRight" format="dimension"/>
|
||||
<attr name="attributionMarginBottom" format="dimension"/>
|
||||
</declare-styleable>
|
||||
</resources>
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<color name="white">#FFFFFF</color>
|
||||
<color name="black">#000000</color>
|
||||
<color name="mapbox_blue">#1E8CAB</color>
|
||||
</resources>
|
||||
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="compassContentDescription">Map compass. Click to reset the map rotation to North.</string>
|
||||
<string name="attributionsIconContentDescription">Attribution icon. Click to show attribution dialog.</string>
|
||||
<string name="attributionsDialogTitle">Mapbox Android SDK</string>
|
||||
<string name="mapboxIconContentDescription">Mapbox logo.</string>
|
||||
<string name="infoWindowTitle">Title</string>
|
||||
<string name="infoWindowDescription">Description</string>
|
||||
<string name="infoWindowAddress">Address</string>
|
||||
</resources>
|
||||
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
|
||||
<style name="AttributionAlertDialogStyle" parent="Theme.AppCompat.Dialog.Alert">
|
||||
<item name="android:textColorPrimary">@android:color/white</item>
|
||||
<item name="android:background">@color/mapbox_blue</item>
|
||||
</style>
|
||||
|
||||
</resources>
|
||||
@@ -1,15 +1,23 @@
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven { url 'https://maven.fabric.io/public' }
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:1.2.3'
|
||||
classpath 'com.android.tools.build:gradle:1.3.0'
|
||||
classpath 'com.jakewharton.sdkmanager:gradle-plugin:0.12.0'
|
||||
classpath 'io.fabric.tools:gradle:1.+'
|
||||
}
|
||||
}
|
||||
|
||||
apply plugin: 'android-sdk-manager'
|
||||
apply plugin: 'com.android.application'
|
||||
apply plugin: 'io.fabric'
|
||||
|
||||
repositories {
|
||||
maven { url 'https://maven.fabric.io/public' }
|
||||
}
|
||||
|
||||
apply plugin: 'checkstyle'
|
||||
|
||||
task accessToken {
|
||||
@@ -30,8 +38,8 @@ gradle.projectsEvaluated {
|
||||
}
|
||||
|
||||
android {
|
||||
compileSdkVersion 22
|
||||
buildToolsVersion "22.0.1"
|
||||
compileSdkVersion 23
|
||||
buildToolsVersion "23.0.1"
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
@@ -39,8 +47,8 @@ android {
|
||||
|
||||
defaultConfig {
|
||||
applicationId "com.mapbox.mapboxgl.testapp"
|
||||
minSdkVersion 8
|
||||
targetSdkVersion 22
|
||||
minSdkVersion 15
|
||||
targetSdkVersion 23
|
||||
versionCode 4
|
||||
versionName "0.1.3"
|
||||
|
||||
@@ -69,7 +77,7 @@ android {
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
|
||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -78,10 +86,13 @@ dependencies {
|
||||
compile(project(':MapboxGLAndroidSDK')) {
|
||||
transitive = true
|
||||
}
|
||||
compile 'com.android.support:support-annotations:22.2.0'
|
||||
compile 'com.android.support:support-v4:22.2.0'
|
||||
compile 'com.android.support:appcompat-v7:22.2.0'
|
||||
compile 'com.mapzen.android:lost:1.0.0'
|
||||
compile 'com.android.support:support-annotations:23.0.1'
|
||||
compile 'com.android.support:support-v4:23.0.1'
|
||||
compile 'com.android.support:appcompat-v7:23.0.1'
|
||||
compile 'com.android.support:design:23.0.1'
|
||||
compile('com.crashlytics.sdk.android:crashlytics:2.5.1@aar') {
|
||||
transitive = true;
|
||||
}
|
||||
|
||||
// Testing dependencies
|
||||
androidTestCompile 'com.android.support.test:runner:0.3'
|
||||
|
||||
1
android/java/MapboxGLAndroidSDKTestApp/proguard-rules.pro
vendored
Normal file
@@ -0,0 +1 @@
|
||||
# Proguard configuration is handeld in the SDK
|
||||
@@ -2,15 +2,12 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools"
|
||||
package="com.mapbox.mapboxgl.testapp">
|
||||
|
||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
||||
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
|
||||
|
||||
<application
|
||||
android:allowBackup="false"
|
||||
android:allowBackup="true"
|
||||
android:fullBackupContent="true"
|
||||
android:icon="@drawable/icon_burned"
|
||||
android:label="@string/app_name"
|
||||
android:theme="@style/AppTheme"
|
||||
tools:ignore="UnusedAttribute"
|
||||
android:supportsRtl="true">
|
||||
<activity
|
||||
android:name="com.mapbox.mapboxgl.testapp.MainActivity"
|
||||
@@ -20,6 +17,12 @@
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<meta-data
|
||||
android:name="io.fabric.ApiKey"
|
||||
android:value="9724157045ff7d083492c6d9ae03e60e8609d461" />
|
||||
</application>
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
|
||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
|
||||
</manifest>
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
{"type":"FeatureCollection","features":[{"type":"Feature","properties":{},"geometry":{"type":"LineString","coordinates":[[-121.3714599609375,38.64583568648869],[-121.48681640624999,38.64047263931154],[-121.53076171875,38.61579745317875],[-121.56509399414061,38.57823196583313],[-121.75186157226561,38.533127435052776],[-121.97021484374999,38.35350340353833],[-122.08007812499999,38.24680876017446],[-122.16796875,38.19718009396176],[-122.23800659179686,38.09457899232253],[-122.27371215820312,38.01455819225337],[-122.33551025390625,37.94094845586459],[-122.27371215820312,37.81846319511331],[-122.4151611328125,37.7652868250379]]}}]}
|
||||
@@ -0,0 +1 @@
|
||||
{"type":"FeatureCollection","features":[{"type":"Feature","properties":{},"geometry":{"type":"Polygon","coordinates":[[[-122.28813171386719,38.617406963286136],[-122.26959228515624,38.6833657775237],[-122.18238830566406,38.55568323796419],[-122.10617065429688,38.51378825951165],[-122.11509704589845,38.50465406475561],[-122.18307495117188,38.542795073979015],[-122.19955444335938,38.496593518947556],[-122.28813171386719,38.617406963286136]]]}}]}
|
||||
@@ -1,81 +1,73 @@
|
||||
package com.mapbox.mapboxgl.testapp;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Matrix;
|
||||
import android.Manifest;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.PointF;
|
||||
import android.hardware.GeomagneticField;
|
||||
import android.hardware.Sensor;
|
||||
import android.hardware.SensorEvent;
|
||||
import android.hardware.SensorEventListener;
|
||||
import android.hardware.SensorManager;
|
||||
import android.location.Location;
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.app.ActionBarActivity;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.design.widget.FloatingActionButton;
|
||||
import android.support.design.widget.NavigationView;
|
||||
import android.support.v4.app.ActivityCompat;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v4.view.GravityCompat;
|
||||
import android.support.v4.widget.DrawerLayout;
|
||||
import android.support.v7.app.ActionBar;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.util.Log;
|
||||
import android.view.GestureDetector;
|
||||
import android.view.MenuItem;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.TextView;
|
||||
|
||||
import android.widget.Toast;
|
||||
import com.crashlytics.android.Crashlytics;
|
||||
import com.mapbox.mapboxgl.annotations.Marker;
|
||||
import com.mapbox.mapboxgl.annotations.MarkerOptions;
|
||||
import com.mapbox.mapboxgl.annotations.PolygonOptions;
|
||||
import com.mapbox.mapboxgl.annotations.PolylineOptions;
|
||||
import com.mapbox.mapboxgl.geometry.LatLng;
|
||||
import com.mapbox.mapboxgl.views.MapView;
|
||||
import com.mapzen.android.lost.api.LocationListener;
|
||||
import com.mapzen.android.lost.api.LocationRequest;
|
||||
import com.mapzen.android.lost.api.LocationServices;
|
||||
import com.mapzen.android.lost.api.LostApiClient;
|
||||
|
||||
import io.fabric.sdk.android.Fabric;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class MainActivity extends ActionBarActivity {
|
||||
public class MainActivity extends AppCompatActivity {
|
||||
|
||||
private static final String TAG = "MainActivity";
|
||||
|
||||
//
|
||||
// Static members
|
||||
//
|
||||
|
||||
// Used for saving instance state
|
||||
private static final String STATE_IS_GPS_ON = "isGpsOn";
|
||||
private static final String STATE_IS_ANNOTATIONS_ON = "isAnnotationsOn";
|
||||
private static final String STATE_SELECTED_STYLE = "selectedStyle";
|
||||
|
||||
// Used for permissions requests
|
||||
private static final int PERMISSIONS_LOCATION = 0;
|
||||
|
||||
//
|
||||
// Instance members
|
||||
//
|
||||
|
||||
// Used for the UI
|
||||
private MapFragment mMapFragment;
|
||||
private DrawerLayout mDrawerLayout;
|
||||
private MapView mMapView;
|
||||
private TextView mFpsTextView;
|
||||
private ImageView mCompassView;
|
||||
private FrameLayout mMapFrameLayout;
|
||||
private float mDensity;
|
||||
private Spinner mClassSpinner;
|
||||
private ArrayAdapter mOutdoorsClassAdapter;
|
||||
private ArrayAdapter mSatelliteClassAdapter;
|
||||
private int mSelectedStyle = R.id.actionStyleMapboxStreets;
|
||||
NavigationView mNavigationView;
|
||||
|
||||
// Used for GPS
|
||||
private boolean mIsGpsOn = false;
|
||||
private LostApiClient mLocationClient;
|
||||
private GpsListener mGpsListener;
|
||||
private LocationRequest mLocationRequest;
|
||||
private ImageView mGpsMarker;
|
||||
private Location mGpsLocation;
|
||||
private MenuItem mGpsMenuItem;
|
||||
private FloatingActionButton mLocationFAB;
|
||||
|
||||
// Used for compass
|
||||
private SensorManager mSensorManager;
|
||||
private Sensor mSensorAccelerometer;
|
||||
private Sensor mSensorMagneticField;
|
||||
private CompassListener mCompassListener;
|
||||
private float[] mValuesAccelerometer = new float[3];
|
||||
private float[] mValuesMagneticField = new float[3];
|
||||
private float[] mMatrixR = new float[9];
|
||||
private float[] mMatrixI = new float[9];
|
||||
private float[] mMatrixValues = new float[3];
|
||||
private float mCompassBearing;
|
||||
private boolean mCompassValid = false;
|
||||
// Used for Annotations
|
||||
private boolean mIsAnnotationsOn = false;
|
||||
|
||||
//
|
||||
// Lifecycle events
|
||||
@@ -85,62 +77,112 @@ public class MainActivity extends ActionBarActivity {
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
if (savedInstanceState != null) {
|
||||
mIsGpsOn = savedInstanceState.getBoolean(STATE_IS_GPS_ON, false);
|
||||
}
|
||||
|
||||
mDensity = getResources().getDisplayMetrics().density;
|
||||
Fabric.with(this, new Crashlytics());
|
||||
|
||||
// Load the layout
|
||||
setContentView(R.layout.activity_main);
|
||||
mMapFragment = (MapFragment) getSupportFragmentManager().findFragmentById(R.id.fragment_map);
|
||||
mMapFragment.getMap().setOnFpsChangedListener(new MyOnFpsChangedListener());
|
||||
mMapFragment.getMap().setOnMapChangedListener(new MyOnMapChangedListener());
|
||||
|
||||
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
|
||||
setSupportActionBar(toolbar);
|
||||
|
||||
final ActionBar ab = getSupportActionBar();
|
||||
if (ab != null) {
|
||||
ab.setHomeAsUpIndicator(R.drawable.ic_menu);
|
||||
ab.setDisplayHomeAsUpEnabled(true);
|
||||
}
|
||||
|
||||
mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
|
||||
|
||||
mNavigationView = (NavigationView) findViewById(R.id.nav_view);
|
||||
if (mNavigationView != null) {
|
||||
setupDrawerContent(mNavigationView);
|
||||
}
|
||||
|
||||
mMapView = (MapView) findViewById(R.id.mainMapView);
|
||||
// Load the access token
|
||||
try {
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(getResources().openRawResource(R.raw.token)));
|
||||
String line = reader.readLine();
|
||||
mMapView.setAccessToken(line);
|
||||
} catch (IOException e) {
|
||||
Log.e(TAG, "Error loading access token from token.txt: " + e.toString());
|
||||
}
|
||||
|
||||
mMapView.onCreate(savedInstanceState);
|
||||
mMapView.setOnFpsChangedListener(new MyOnFpsChangedListener());
|
||||
|
||||
final GestureDetector gestureDetector = new GestureDetector(this, new GestureDetector.SimpleOnGestureListener() {
|
||||
public void onLongPress(final MotionEvent e) {
|
||||
float x = e.getX();
|
||||
float y = e.getY();
|
||||
|
||||
// flip y direction vertically to match core GL
|
||||
y = mMapView.getHeight() - y;
|
||||
|
||||
LatLng position = mMapView.fromScreenLocation(new PointF(x, y));
|
||||
|
||||
mMapView.addMarker(new MarkerOptions()
|
||||
.position(position)
|
||||
.title("Dropped Pin")
|
||||
.snippet(new DecimalFormat("#.#####").format(position.getLatitude()) + ", " +
|
||||
new DecimalFormat("#.#####").format(position.getLongitude()))
|
||||
.sprite("default_marker"));
|
||||
}
|
||||
});
|
||||
|
||||
mMapView.setOnTouchListener(new View.OnTouchListener() {
|
||||
public boolean onTouch(View v, MotionEvent event) {
|
||||
return gestureDetector.onTouchEvent(event);
|
||||
}
|
||||
});
|
||||
|
||||
mFpsTextView = (TextView) findViewById(R.id.view_fps);
|
||||
mFpsTextView.setText("");
|
||||
|
||||
mCompassView = (ImageView) findViewById(R.id.view_compass);
|
||||
mCompassView.setOnClickListener(new CompassOnClickListener());
|
||||
mLocationFAB = (FloatingActionButton)findViewById(R.id.locationFAB);
|
||||
mLocationFAB.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
// Toggle GPS position updates
|
||||
toggleGps(!mMapView.isMyLocationEnabled());
|
||||
if (mMapView.isMyLocationEnabled()) {
|
||||
Location location = mMapView.getMyLocation();
|
||||
if (location != null) {
|
||||
mMapView.setZoomLevel(8);
|
||||
mMapView.setCenterCoordinate(new LatLng(location));
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
mGpsMarker = new ImageView(getApplicationContext());
|
||||
mGpsMarker.setVisibility(View.INVISIBLE);
|
||||
mGpsMarker.setImageResource(R.drawable.location_marker);
|
||||
mGpsMarker.setLayoutParams(new FrameLayout.LayoutParams((int) (27.0f * mDensity), (int) (27.0f * mDensity)));
|
||||
mGpsMarker.requestLayout();
|
||||
// Restore saved state
|
||||
if (savedInstanceState != null) {
|
||||
mIsAnnotationsOn = savedInstanceState.getBoolean(STATE_IS_ANNOTATIONS_ON);
|
||||
mSelectedStyle = savedInstanceState.getInt(STATE_SELECTED_STYLE);
|
||||
}
|
||||
|
||||
mMapFrameLayout = (FrameLayout) findViewById(R.id.layout_map);
|
||||
mMapFrameLayout.addView(mGpsMarker);
|
||||
// Add a toolbar as the action bar
|
||||
Toolbar mainToolbar = (Toolbar) findViewById(R.id.toolbar_main);
|
||||
setSupportActionBar(mainToolbar);
|
||||
getSupportActionBar().setDisplayShowTitleEnabled(false);
|
||||
// Set default UI state
|
||||
mNavigationView.getMenu().findItem(R.id.action_compass).setChecked(mMapView.isCompassEnabled());
|
||||
mNavigationView.getMenu().findItem(R.id.action_debug).setChecked(mMapView.isDebugActive());
|
||||
mNavigationView.getMenu().findItem(R.id.action_markers).setChecked(mIsAnnotationsOn);
|
||||
changeMapStyle(mSelectedStyle);
|
||||
toggleGps(mMapView.isMyLocationEnabled());
|
||||
}
|
||||
|
||||
// Add the spinner to select map styles
|
||||
Spinner styleSpinner = (Spinner) findViewById(R.id.spinner_style);
|
||||
ArrayAdapter styleAdapter = ArrayAdapter.createFromResource(getSupportActionBar().getThemedContext(),
|
||||
R.array.style_list, android.R.layout.simple_spinner_dropdown_item);
|
||||
styleSpinner.setAdapter(styleAdapter);
|
||||
styleSpinner.setOnItemSelectedListener(new StyleSpinnerListener());
|
||||
/**
|
||||
* Dispatch onStart() to all fragments. Ensure any created loaders are
|
||||
* now started.
|
||||
*/
|
||||
@Override
|
||||
protected void onStart() {
|
||||
super.onStart();
|
||||
mMapView.onStart();
|
||||
}
|
||||
|
||||
// Add the spinner to select class styles
|
||||
mClassSpinner = (Spinner) findViewById(R.id.spinner_class);
|
||||
mOutdoorsClassAdapter = ArrayAdapter.createFromResource(getSupportActionBar().getThemedContext(),
|
||||
R.array.outdoors_class_list, android.R.layout.simple_spinner_dropdown_item);
|
||||
|
||||
// Prepare for GPS
|
||||
mLocationClient = new LostApiClient.Builder(this).build();
|
||||
mLocationRequest = LocationRequest.create()
|
||||
.setInterval(1000)
|
||||
.setSmallestDisplacement(1)
|
||||
.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
|
||||
mGpsListener = new GpsListener();
|
||||
|
||||
mSensorManager = (SensorManager) getApplicationContext().getSystemService(Context.SENSOR_SERVICE);
|
||||
mSensorAccelerometer = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
|
||||
mSensorMagneticField = mSensorManager.getDefaultSensor(Sensor.TYPE_MAGNETIC_FIELD);
|
||||
mCompassListener = new CompassListener();
|
||||
@Override
|
||||
protected void onStop() {
|
||||
super.onStop();
|
||||
mMapView.onStop();
|
||||
}
|
||||
|
||||
// Called when our app goes into the background
|
||||
@@ -148,16 +190,21 @@ public class MainActivity extends ActionBarActivity {
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
|
||||
// Cancel GPS
|
||||
toggleGps(false);
|
||||
mMapView.onPause();
|
||||
}
|
||||
|
||||
// Called when our app comes into the foreground
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
// Restart GPS
|
||||
toggleGps(true);
|
||||
|
||||
mMapView.onResume();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
mMapView.onDestroy();
|
||||
}
|
||||
|
||||
// Called when we need to save instance state
|
||||
@@ -165,53 +212,139 @@ public class MainActivity extends ActionBarActivity {
|
||||
protected void onSaveInstanceState(Bundle outState) {
|
||||
super.onSaveInstanceState(outState);
|
||||
|
||||
outState.putBoolean(STATE_IS_GPS_ON, mIsGpsOn);
|
||||
mMapView.onSaveInstanceState(outState);
|
||||
outState.putBoolean(STATE_IS_ANNOTATIONS_ON, mIsAnnotationsOn);
|
||||
outState.putInt(STATE_SELECTED_STYLE, mSelectedStyle);
|
||||
}
|
||||
|
||||
// Called when the system is running low on memory
|
||||
@Override
|
||||
public void onLowMemory() {
|
||||
super.onLowMemory();
|
||||
|
||||
mMapView.onLowMemory();
|
||||
}
|
||||
|
||||
//
|
||||
// Other events
|
||||
//
|
||||
|
||||
// Adds items to the action bar menu
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
MenuInflater inflater = getMenuInflater();
|
||||
inflater.inflate(R.menu.menu_main, menu);
|
||||
mGpsMenuItem = menu.findItem(R.id.action_gps);
|
||||
if (mIsGpsOn) {
|
||||
mGpsMenuItem.setIcon(R.drawable.ic_action_location_found);
|
||||
} else {
|
||||
mGpsMenuItem.setIcon(R.drawable.ic_action_location_searching);
|
||||
}
|
||||
return super.onCreateOptionsMenu(menu);
|
||||
}
|
||||
|
||||
// Called when pressing action bar items
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case R.id.action_gps:
|
||||
// Toggle GPS position updates
|
||||
toggleGps(!mIsGpsOn);
|
||||
updateMap();
|
||||
case android.R.id.home:
|
||||
mDrawerLayout.openDrawer(GravityCompat.START);
|
||||
return true;
|
||||
default:
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRequestPermissionsResult(int requestCode, @NonNull String permissions[], @NonNull int[] grantResults) {
|
||||
switch (requestCode) {
|
||||
case PERMISSIONS_LOCATION: {
|
||||
if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
||||
enableGps();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void setupDrawerContent(NavigationView navigationView) {
|
||||
navigationView.setNavigationItemSelectedListener(
|
||||
new NavigationView.OnNavigationItemSelectedListener() {
|
||||
@Override
|
||||
public boolean onNavigationItemSelected(MenuItem menuItem) {
|
||||
mDrawerLayout.closeDrawers();
|
||||
|
||||
// Respond To Selection
|
||||
switch (menuItem.getItemId()) {
|
||||
|
||||
case R.id.action_debug:
|
||||
// Toggle debug mode
|
||||
mMapView.toggleDebug();
|
||||
toggleFpsCounter(mMapView.isDebugActive());
|
||||
menuItem.setChecked(mMapView.isDebugActive());
|
||||
return true;
|
||||
|
||||
case R.id.action_markers:
|
||||
// Toggle markers
|
||||
toggleAnnotations(!mIsAnnotationsOn);
|
||||
menuItem.setChecked(mIsAnnotationsOn);
|
||||
return true;
|
||||
|
||||
case R.id.action_compass:
|
||||
// Toggle compass
|
||||
mMapView.setCompassEnabled(!mMapView.isCompassEnabled());
|
||||
menuItem.setChecked(mMapView.isCompassEnabled());
|
||||
return true;
|
||||
|
||||
/*
|
||||
case R.id.followNone:
|
||||
mMapView.setUserLocationTrackingMode(MapView.UserLocationTrackingMode.NONE);
|
||||
return true;
|
||||
|
||||
case R.id.followFollow:
|
||||
mMapView.setUserLocationTrackingMode(MapView.UserLocationTrackingMode.FOLLOW);
|
||||
return true;
|
||||
|
||||
case R.id.followBearing:
|
||||
mMapView.setUserLocationTrackingMode(MapView.UserLocationTrackingMode.FOLLOW_BEARING);
|
||||
return true;
|
||||
*/
|
||||
default:
|
||||
return changeMapStyle(menuItem.getItemId());
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void toggleFpsCounter(boolean enableFps) {
|
||||
// Show the FPS counter
|
||||
if (enableFps) {
|
||||
mFpsTextView.setVisibility(View.VISIBLE);
|
||||
mFpsTextView.setText(getResources().getString(R.string.label_fps));
|
||||
} else {
|
||||
mFpsTextView.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean changeMapStyle(int id) {
|
||||
switch (id) {
|
||||
case R.id.actionStyleMapboxStreets:
|
||||
mMapView.setStyleUrl(getString(R.string.styleURLMapboxStreets));
|
||||
mNavigationView.getMenu().findItem(id).setChecked(true);
|
||||
mSelectedStyle = id;
|
||||
return true;
|
||||
|
||||
case R.id.action_debug:
|
||||
// Toggle debug mode
|
||||
mMapFragment.getMap().toggleDebug();
|
||||
case R.id.actionStyleEmerald:
|
||||
mMapView.setStyleUrl(getString(R.string.styleURLEmerald));
|
||||
mNavigationView.getMenu().findItem(id).setChecked(true);
|
||||
mSelectedStyle = id;
|
||||
return true;
|
||||
|
||||
// Show the FPS counter
|
||||
if (mMapFragment.getMap().isDebugActive()) {
|
||||
mFpsTextView.setVisibility(View.VISIBLE);
|
||||
mFpsTextView.setText(getResources().getString(R.string.label_fps));
|
||||
} else {
|
||||
mFpsTextView.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
case R.id.actionStyleLight:
|
||||
mMapView.setStyleUrl(getString(R.string.styleURLLight));
|
||||
mNavigationView.getMenu().findItem(id).setChecked(true);
|
||||
mSelectedStyle = id;
|
||||
return true;
|
||||
|
||||
case R.id.actionStyleDark:
|
||||
mMapView.setStyleUrl(getString(R.string.styleURLDark));
|
||||
mNavigationView.getMenu().findItem(id).setChecked(true);
|
||||
mSelectedStyle = id;
|
||||
return true;
|
||||
|
||||
case R.id.actionStyleSatellite:
|
||||
mMapView.setStyleUrl(getString(R.string.styleURLSatellite));
|
||||
mNavigationView.getMenu().findItem(id).setChecked(true);
|
||||
mSelectedStyle = id;
|
||||
return true;
|
||||
|
||||
default:
|
||||
return super.onOptionsItemSelected(item);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -220,228 +353,105 @@ public class MainActivity extends ActionBarActivity {
|
||||
* @param enableGps true if GPS is to be enabled, false if GPS is to be disabled
|
||||
*/
|
||||
private void toggleGps(boolean enableGps) {
|
||||
|
||||
if (enableGps) {
|
||||
if (!mIsGpsOn) {
|
||||
mIsGpsOn = true;
|
||||
if (mGpsMenuItem != null) {
|
||||
mGpsMenuItem.setIcon(R.drawable.ic_action_location_found);
|
||||
}
|
||||
mGpsLocation = null;
|
||||
mLocationClient.connect();
|
||||
updateLocation(LocationServices.FusedLocationApi.getLastLocation());
|
||||
LocationServices.FusedLocationApi.requestLocationUpdates(mLocationRequest, new GpsListener());
|
||||
mSensorManager.registerListener(mCompassListener, mSensorAccelerometer, SensorManager.SENSOR_DELAY_UI);
|
||||
mSensorManager.registerListener(mCompassListener, mSensorMagneticField, SensorManager.SENSOR_DELAY_UI);
|
||||
if ((ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) ||
|
||||
(ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED))
|
||||
{
|
||||
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION}, PERMISSIONS_LOCATION);
|
||||
} else {
|
||||
enableGps();
|
||||
}
|
||||
} else {
|
||||
if (mIsGpsOn) {
|
||||
mIsGpsOn = false;
|
||||
if (mGpsMenuItem != null) {
|
||||
mGpsMenuItem.setIcon(R.drawable.ic_action_location_searching);
|
||||
}
|
||||
LocationServices.FusedLocationApi.removeLocationUpdates(mGpsListener);
|
||||
mLocationClient.disconnect();
|
||||
mSensorManager.unregisterListener(mCompassListener, mSensorAccelerometer);
|
||||
mSensorManager.unregisterListener(mCompassListener, mSensorMagneticField);
|
||||
mGpsLocation = null;
|
||||
mMapView.setMyLocationEnabled(false);
|
||||
mLocationFAB.setColorFilter(Color.TRANSPARENT);
|
||||
}
|
||||
}
|
||||
|
||||
private void enableGps() {
|
||||
mMapView.setMyLocationEnabled(true);
|
||||
mLocationFAB.setColorFilter(ContextCompat.getColor(this, R.color.primary));
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable / Disable Annotations.
|
||||
*
|
||||
* @param enableAnnotations True to display, False to hide
|
||||
*/
|
||||
private void toggleAnnotations(boolean enableAnnotations) {
|
||||
if (enableAnnotations) {
|
||||
if (!mIsAnnotationsOn) {
|
||||
mIsAnnotationsOn = true;
|
||||
addMarkers();
|
||||
addPolyline();
|
||||
addPolygon();
|
||||
mMapView.setZoomLevel(7);
|
||||
mMapView.setCenterCoordinate(new LatLng(38.11727, -122.22839));
|
||||
}
|
||||
} else {
|
||||
if (mIsAnnotationsOn) {
|
||||
mIsAnnotationsOn = false;
|
||||
removeAnnotations();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// This class forwards location updates to updateLocation()
|
||||
private class GpsListener implements LocationListener {
|
||||
private void addMarkers() {
|
||||
LatLng backLot = new LatLng(38.649441, -121.369064);
|
||||
final Marker marker = mMapView.addMarker(new MarkerOptions()
|
||||
.position(backLot)
|
||||
.title("Back Lot")
|
||||
.snippet("The back lot behind my house"));
|
||||
marker.setInfoWindowOnTouchListener(new View.OnTouchListener() {
|
||||
@Override
|
||||
public boolean onTouch(View view, MotionEvent motionEvent) {
|
||||
Toast.makeText(getApplicationContext(), "Custom Info Touch Listener!!", Toast.LENGTH_SHORT).show();
|
||||
marker.hideInfoWindow();
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
@Override
|
||||
public void onLocationChanged(Location location) {
|
||||
updateLocation(location);
|
||||
LatLng cheeseRoom = new LatLng(38.531577,-122.010646);
|
||||
mMapView.addMarker(new MarkerOptions()
|
||||
.position(cheeseRoom)
|
||||
.sprite("dog-park-15")
|
||||
.title("Cheese Room")
|
||||
.snippet("The only air conditioned room on the property!"));
|
||||
}
|
||||
|
||||
private void addPolyline() {
|
||||
try {
|
||||
String geojsonStr = Util.loadStringFromAssets(this, "small_line.geojson");
|
||||
LatLng[] latLngs = Util.parseGeoJSONCoordinates(geojsonStr);
|
||||
MapView map = mMapView;
|
||||
map.addPolyline(new PolylineOptions()
|
||||
.add(latLngs)
|
||||
.width(2)
|
||||
.color(Color.RED));
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "Error adding Polyline: "+ e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
// This class handles sensor updates to calculate compass bearing
|
||||
private class CompassListener implements SensorEventListener {
|
||||
|
||||
@Override
|
||||
public void onSensorChanged(SensorEvent event) {
|
||||
switch (event.sensor.getType()) {
|
||||
case Sensor.TYPE_ACCELEROMETER:
|
||||
System.arraycopy(event.values, 0, mValuesAccelerometer, 0, 3);
|
||||
break;
|
||||
case Sensor.TYPE_MAGNETIC_FIELD:
|
||||
System.arraycopy(event.values, 0, mValuesMagneticField, 0, 3);
|
||||
break;
|
||||
}
|
||||
|
||||
boolean valid = SensorManager.getRotationMatrix(mMatrixR, mMatrixI,
|
||||
mValuesAccelerometer,
|
||||
mValuesMagneticField);
|
||||
|
||||
if (valid) {
|
||||
SensorManager.getOrientation(mMatrixR, mMatrixValues);
|
||||
//mAzimuthRadians.putValue(mMatrixValues[0]);
|
||||
//mAzimuth = Math.toDegrees(mAzimuthRadians.getAverage());
|
||||
|
||||
if (mGpsLocation != null) {
|
||||
GeomagneticField geomagneticField = new GeomagneticField(
|
||||
(float) mGpsLocation.getLatitude(),
|
||||
(float) mGpsLocation.getLongitude(),
|
||||
(float) mGpsLocation.getAltitude(),
|
||||
System.currentTimeMillis());
|
||||
mCompassBearing = (float) Math.toDegrees(mMatrixValues[0]) + geomagneticField.getDeclination();
|
||||
mCompassValid = true;
|
||||
}
|
||||
}
|
||||
|
||||
updateMap();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAccuracyChanged(Sensor sensor, int accuracy) {
|
||||
// TODO: ignore unreliable stuff
|
||||
private void addPolygon() {
|
||||
try {
|
||||
String geojsonStr = Util.loadStringFromAssets(this, "small_poly.geojson");
|
||||
LatLng[] latLngs = Util.parseGeoJSONCoordinates(geojsonStr);
|
||||
MapView map = mMapView;
|
||||
ArrayList<PolygonOptions> opts = new ArrayList<>();
|
||||
opts.add(new PolygonOptions()
|
||||
.add(latLngs)
|
||||
.strokeColor(Color.MAGENTA)
|
||||
.fillColor(Color.BLUE));
|
||||
map.addPolygons(opts).get(0);
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "Error adding Polygon: "+ e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
// Handles location updates from GPS
|
||||
private void updateLocation(Location location) {
|
||||
if (location != null) {
|
||||
mGpsLocation = location;
|
||||
}
|
||||
|
||||
updateMap();
|
||||
}
|
||||
|
||||
// This class handles style change events
|
||||
private class StyleSpinnerListener implements AdapterView.OnItemSelectedListener {
|
||||
|
||||
@Override
|
||||
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
||||
switch (position) {
|
||||
|
||||
// Mapbox Streets
|
||||
case 0:
|
||||
mMapFragment.getMap().setStyleUrl("asset://styles/mapbox-streets-v7.json");
|
||||
mMapFragment.getMap().removeAllClasses();
|
||||
mClassSpinner.setVisibility(View.INVISIBLE);
|
||||
mClassSpinner.setAdapter(null);
|
||||
mClassSpinner.setOnItemSelectedListener(null);
|
||||
break;
|
||||
|
||||
// Emerald
|
||||
case 1:
|
||||
mMapFragment.getMap().setStyleUrl("asset://styles/emerald-v7.json");
|
||||
mMapFragment.getMap().removeAllClasses();
|
||||
mClassSpinner.setVisibility(View.INVISIBLE);
|
||||
mClassSpinner.setAdapter(null);
|
||||
mClassSpinner.setOnItemSelectedListener(null);
|
||||
break;
|
||||
|
||||
// Light
|
||||
case 2:
|
||||
mMapFragment.getMap().setStyleUrl("asset://styles/light-v7.json");
|
||||
mMapFragment.getMap().removeAllClasses();
|
||||
mClassSpinner.setVisibility(View.INVISIBLE);
|
||||
mClassSpinner.setAdapter(null);
|
||||
mClassSpinner.setOnItemSelectedListener(null);
|
||||
break;
|
||||
|
||||
// Dark
|
||||
case 3:
|
||||
mMapFragment.getMap().setStyleUrl("asset://styles/dark-v7.json");
|
||||
mMapFragment.getMap().removeAllClasses();
|
||||
mClassSpinner.setVisibility(View.INVISIBLE);
|
||||
mClassSpinner.setAdapter(null);
|
||||
mClassSpinner.setOnItemSelectedListener(null);
|
||||
break;
|
||||
|
||||
// Outdoors
|
||||
case 4:
|
||||
mMapFragment.getMap().setStyleUrl("asset://styles/outdoors-v7.json");
|
||||
mMapFragment.getMap().removeAllClasses();
|
||||
mClassSpinner.setVisibility(View.VISIBLE);
|
||||
mClassSpinner.setAdapter(mOutdoorsClassAdapter);
|
||||
mClassSpinner.setOnItemSelectedListener(new OutdoorClassSpinnerListener());
|
||||
break;
|
||||
|
||||
default:
|
||||
onNothingSelected(parent);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNothingSelected(AdapterView<?> parent) {
|
||||
mMapFragment.getMap().setStyleUrl("");
|
||||
}
|
||||
}
|
||||
|
||||
// This class handles outdoor class change events
|
||||
private class OutdoorClassSpinnerListener implements AdapterView.OnItemSelectedListener {
|
||||
|
||||
@Override
|
||||
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
||||
ArrayList<String> classes = new ArrayList<>(1);
|
||||
|
||||
switch (position) {
|
||||
// Day
|
||||
case 0:
|
||||
classes.add("day");
|
||||
mMapFragment.getMap().setClasses(classes);
|
||||
break;
|
||||
|
||||
// Night
|
||||
case 1:
|
||||
classes.add("night");
|
||||
mMapFragment.getMap().setClasses(classes);
|
||||
break;
|
||||
|
||||
default:
|
||||
onNothingSelected(parent);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNothingSelected(AdapterView<?> parent) {
|
||||
mMapFragment.getMap().removeAllClasses();
|
||||
}
|
||||
}
|
||||
|
||||
// This class handles satellite class change events
|
||||
private class SatelliteClassSpinnerListener implements AdapterView.OnItemSelectedListener {
|
||||
|
||||
@Override
|
||||
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
||||
ArrayList<String> classes = new ArrayList<>(2);
|
||||
|
||||
switch (position) {
|
||||
// Labels + Contours
|
||||
case 0:
|
||||
classes.add("labels");
|
||||
classes.add("contours");
|
||||
mMapFragment.getMap().setClasses(classes);
|
||||
break;
|
||||
|
||||
// Labels Only
|
||||
case 1:
|
||||
classes.add("labels");
|
||||
mMapFragment.getMap().setClasses(classes);
|
||||
break;
|
||||
|
||||
// No Labels
|
||||
case 2:
|
||||
mMapFragment.getMap().setClasses(classes);
|
||||
break;
|
||||
|
||||
default:
|
||||
onNothingSelected(parent);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNothingSelected(AdapterView<?> parent) {
|
||||
mMapFragment.getMap().removeAllClasses();
|
||||
}
|
||||
private void removeAnnotations() {
|
||||
mMapView.removeAnnotations();
|
||||
}
|
||||
|
||||
// Called when FPS changes
|
||||
@@ -453,62 +463,4 @@ public class MainActivity extends ActionBarActivity {
|
||||
}
|
||||
}
|
||||
|
||||
// Rotates an ImageView - does not work if the ImageView has padding, use margins
|
||||
private void rotateImageView(ImageView imageView, float angle) {
|
||||
Matrix matrix = new Matrix();
|
||||
matrix.setScale((float) imageView.getWidth() / (float) imageView.getDrawable().getIntrinsicWidth(), (float) imageView.getHeight() / (float) imageView.getDrawable().getIntrinsicHeight());
|
||||
matrix.postRotate(angle, (float) imageView.getWidth() / 2.0f, (float) imageView.getHeight() / 2.0f);
|
||||
imageView.setImageMatrix(matrix);
|
||||
imageView.setScaleType(ImageView.ScaleType.MATRIX);
|
||||
}
|
||||
|
||||
// Updates the UI to match the current map's position
|
||||
private void updateMap() {
|
||||
rotateImageView(mCompassView, (float) mMapFragment.getMap().getDirection());
|
||||
|
||||
if (mGpsLocation != null) {
|
||||
mGpsMarker.setVisibility(View.VISIBLE);
|
||||
LatLng coordinate = new LatLng(mGpsLocation);
|
||||
PointF screenLocation = mMapFragment.getMap().toScreenLocation(coordinate);
|
||||
|
||||
if (mGpsLocation.hasBearing() || mCompassValid) {
|
||||
mGpsMarker.setImageResource(R.drawable.direction_arrow);
|
||||
FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams((int) (54.0f * mDensity), (int) (54.0f * mDensity));
|
||||
lp.leftMargin = (int) ((screenLocation.x - 54.0f / 2.0f) * mDensity);
|
||||
lp.topMargin = mMapFrameLayout.getHeight() - (int) ((screenLocation.y + 54.0f / 2.0f) * mDensity);
|
||||
mGpsMarker.setLayoutParams(lp);
|
||||
float bearing = mGpsLocation.hasBearing() ? mGpsLocation.getBearing() : mCompassBearing;
|
||||
rotateImageView(mGpsMarker, bearing);
|
||||
mGpsMarker.requestLayout();
|
||||
} else {
|
||||
mGpsMarker.setImageResource(R.drawable.location_marker);
|
||||
FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams((int) (27.0f * mDensity), (int) (27.0f * mDensity));
|
||||
lp.leftMargin = (int) ((screenLocation.x - 27.0f / 2.0f) * mDensity);
|
||||
lp.topMargin = mMapFrameLayout.getHeight() - (int) ((screenLocation.y + 27.0f / 2.0f) * mDensity);
|
||||
mGpsMarker.setLayoutParams(lp);
|
||||
rotateImageView(mGpsMarker, 0.0f);
|
||||
mGpsMarker.requestLayout();
|
||||
}
|
||||
} else {
|
||||
mGpsMarker.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
// Called when map state changes
|
||||
private class MyOnMapChangedListener implements MapView.OnMapChangedListener {
|
||||
|
||||
@Override
|
||||
public void onMapChanged() {
|
||||
updateMap();
|
||||
}
|
||||
}
|
||||
|
||||
// Called when someone presses the compass
|
||||
private class CompassOnClickListener implements View.OnClickListener {
|
||||
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
mMapFragment.getMap().resetNorth();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,10 +9,6 @@ import android.view.ViewGroup;
|
||||
|
||||
import com.mapbox.mapboxgl.views.MapView;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
|
||||
public class MapFragment extends Fragment {
|
||||
|
||||
//
|
||||
@@ -42,15 +38,6 @@ public class MapFragment extends Fragment {
|
||||
// Create the map
|
||||
mMap = (MapView) inflater.inflate(R.layout.fragment_main, container, true);
|
||||
|
||||
// Load the access token
|
||||
try {
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(getActivity().getApplicationContext().getResources().openRawResource(R.raw.token)));
|
||||
String line = reader.readLine();
|
||||
mMap.setAccessToken(line);
|
||||
} catch (IOException e) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Need to pass on any saved state to the map
|
||||
mMap.onCreate(savedInstanceState);
|
||||
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
package com.mapbox.mapboxgl.testapp;
|
||||
|
||||
import android.content.Context;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.mapbox.mapboxgl.geometry.LatLng;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.Reader;
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
public class Util {
|
||||
|
||||
public static String loadStringFromAssets(final Context context, final String fileName) throws IOException {
|
||||
if (TextUtils.isEmpty(fileName)) {
|
||||
throw new NullPointerException("No GeoJSON File Name passed in.");
|
||||
}
|
||||
InputStream is = context.getAssets().open(fileName);
|
||||
BufferedReader rd = new BufferedReader(new InputStreamReader(is, Charset.forName("UTF-8")));
|
||||
return readAll(rd);
|
||||
}
|
||||
|
||||
public static LatLng[] parseGeoJSONCoordinates(String geojsonStr) throws JSONException {
|
||||
JSONObject jsonObject = new JSONObject(geojsonStr);
|
||||
JSONArray features = jsonObject.getJSONArray("features");
|
||||
JSONObject feature = features.getJSONObject(0);
|
||||
JSONObject geometry = feature.getJSONObject("geometry");
|
||||
String type = geometry.getString("type");
|
||||
JSONArray coordinates;
|
||||
if (type.equals("Polygon")) {
|
||||
coordinates = geometry.getJSONArray("coordinates").getJSONArray(0);
|
||||
} else {
|
||||
coordinates = geometry.getJSONArray("coordinates");
|
||||
}
|
||||
int len = coordinates.length();
|
||||
LatLng[] latLngs = new LatLng[coordinates.length()];
|
||||
for (int i = 0; i < len; ++i) {
|
||||
JSONArray coord = coordinates.getJSONArray(i);
|
||||
double lng = coord.getDouble(0);
|
||||
double lat = coord.getDouble(1);
|
||||
latLngs[i] = new LatLng(lat, lng);
|
||||
}
|
||||
return latLngs;
|
||||
}
|
||||
|
||||
private static String readAll(Reader rd) throws IOException {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
int cp;
|
||||
while ((cp = rd.read()) != -1) {
|
||||
sb.append((char) cp);
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
Before Width: | Height: | Size: 7.9 KiB |
|
Before Width: | Height: | Size: 683 B |
|
Before Width: | Height: | Size: 722 B |
|
Before Width: | Height: | Size: 641 B |
|
After Width: | Height: | Size: 116 B |
|
After Width: | Height: | Size: 549 B |
|
Before Width: | Height: | Size: 5.2 KiB |
|
Before Width: | Height: | Size: 2.3 KiB |
|
Before Width: | Height: | Size: 6.0 KiB |
|
Before Width: | Height: | Size: 465 B |
|
Before Width: | Height: | Size: 484 B |
|
Before Width: | Height: | Size: 482 B |
|
After Width: | Height: | Size: 99 B |
|
After Width: | Height: | Size: 341 B |
|
Before Width: | Height: | Size: 10 KiB |