Skip to content

Commit

Permalink
Merge branch 'main' into ios-ci-github-runner
Browse files Browse the repository at this point in the history
  • Loading branch information
louwers authored Oct 5, 2024
2 parents a2d949c + 2972708 commit d305bea
Show file tree
Hide file tree
Showing 29 changed files with 341 additions and 59 deletions.
2 changes: 1 addition & 1 deletion .bazelversion
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7.2.1
7.3.1
4 changes: 4 additions & 0 deletions .github/workflows/gh-pages-android-api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ name: gh-pages-android-api

on:
workflow_dispatch:
workflow_run:
workflows: [android-release]
types:
- completed

jobs:
gh-pages-android-api:
Expand Down
9 changes: 5 additions & 4 deletions .github/workflows/node-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -246,11 +246,12 @@ jobs:
- name: Configure maplibre-native (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
cmake . -B build \
-G Ninja \
-DCMAKE_BUILD_TYPE=${{ env.BUILDTYPE }} \
-DCMAKE_CXX_COMPILER_LAUNCHER=sccache \
cmake . -B build `
-G Ninja `
-DCMAKE_BUILD_TYPE=${{ env.BUILDTYPE }} `
-DCMAKE_CXX_COMPILER_LAUNCHER=sccache `
-DMLN_WITH_NODE=ON
- name: Build maplibre-native (MacOS/Linux)
Expand Down
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ repos:
- id: check-yaml
args: [--allow-multiple-documents]
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v18.1.8
rev: v19.1.0
hooks:
- id: clang-format
files: '.*\.(hpp|cpp|h)'
Expand All @@ -15,12 +15,12 @@ repos:
hooks:
- id: buildifier
- repo: https://github.com/Mateusz-Grzelinski/actionlint-py
rev: v1.7.1.15
rev: v1.7.2.16
hooks:
- id: actionlint
additional_dependencies: [shellcheck-py]
- repo: https://github.com/nicklockwood/SwiftFormat
rev: "0.54.3"
rev: "0.54.5"
hooks:
- id: swiftformat
args: [--swiftversion, "5.8"]
Expand Down
8 changes: 4 additions & 4 deletions MODULE.bazel
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
module(name = "maplibre")

bazel_dep(name = "apple_support", version = "1.16.0", repo_name = "build_bazel_apple_support")
bazel_dep(name = "apple_support", version = "1.17.0", repo_name = "build_bazel_apple_support")
bazel_dep(name = "bazel_skylib", version = "1.7.1")
bazel_dep(name = "platforms", version = "0.0.10")
bazel_dep(name = "rules_apple", version = "3.7.0", repo_name = "build_bazel_rules_apple")
bazel_dep(name = "rules_swift", version = "2.1.1", repo_name = "build_bazel_rules_swift")
bazel_dep(name = "rules_xcodeproj", version = "2.5.2")
bazel_dep(name = "aspect_rules_js", version = "2.0.0")
bazel_dep(name = "rules_nodejs", version = "6.2.0")
bazel_dep(name = "rules_xcodeproj", version = "2.7.0")
bazel_dep(name = "aspect_rules_js", version = "2.0.1")
bazel_dep(name = "rules_nodejs", version = "6.3.0")

node = use_extension("@rules_nodejs//nodejs:extensions.bzl", "node", dev_dependency = True)
node.toolchain(node_version = "20.14.0")
Expand Down
216 changes: 193 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,42 +14,212 @@ This project originated as a fork of Mapbox GL Native, before their switch to a

## Getting Started

To get started with MapLibre Native, go to your platform below.
## Android

Add [the latest version](https://central.sonatype.com/artifact/org.maplibre.gl/android-sdk/versions) of MapLibre Native Android as a dependency to your project.

```gradle
dependencies {
...
implementation 'org.maplibre.gl:android-sdk:11.5.1'
...
}
```

Add a `MapView` to your layout XML file:

```xml
<org.maplibre.android.maps.MapView
android:id="@+id/mapView"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
```

> [!TIP]
> There are external projects such as [Ramani Maps](https://github.com/ramani-maps/ramani-maps) and [MapLibre Compose Playground](https://github.com/Rallista/maplibre-compose-playground) available to intergrate MapLibre Native Android with Compose-based projects.
Next, initialize the map in an activity:

<details><summary>Show code</summary>

```kotlin
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.view.LayoutInflater
import org.maplibre.android.Maplibre
import org.maplibre.android.camera.CameraPosition
import org.maplibre.android.geometry.LatLng
import org.maplibre.android.maps.MapView
import org.maplibre.android.testapp.R

class MainActivity : AppCompatActivity() {

// Declare a variable for MapView
private lateinit var mapView: MapView

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

## Documentation
// Init MapLibre
MapLibre.getInstance(this)

- [Android API Documentation](https://maplibre.org/maplibre-native/android/api/), [Android Quickstart](https://maplibre.org/maplibre-native/docs/book/android/getting-started-guide.html)
- [iOS Documentation](https://maplibre.org/maplibre-native/ios/latest/documentation/maplibre/)
// Init layout view
val inflater = LayoutInflater.from(this)
val rootView = inflater.inflate(R.layout.activity_main, null)
setContentView(rootView)

// Init the MapView
mapView = rootView.findViewById(R.id.mapView)
mapView.getMapAsync { map ->
map.setStyle("https://demotiles.maplibre.org/style.json")
map.cameraPosition = CameraPosition.Builder().target(LatLng(0.0,0.0)).zoom(1.0).build()
}
}

override fun onStart() {
super.onStart()
mapView.onStart()
}

override fun onResume() {
super.onResume()
mapView.onResume()
}

override fun onPause() {
super.onPause()
mapView.onPause()
}

override fun onStop() {
super.onStop()
mapView.onStop()
}

override fun onLowMemory() {
super.onLowMemory()
mapView.onLowMemory()
}

override fun onDestroy() {
super.onDestroy()
mapView.onDestroy()
}

override fun onSaveInstanceState(outState: Bundle) {
super.onSaveInstanceState(outState)
mapView.onSaveInstanceState(outState)
}
}
```
</details>

For more information, refer to the [Android API Documentation](https://maplibre.org/maplibre-native/android/api/), [Android Examples Documentation](https://maplibre.org/maplibre-native/docs/book/android/getting-started-guide.html) or the [MapLibre Native Android `README.md`](platform/android/README.md).

## iOS

You can find MapLibre Native iOS on [Cocoapods](https://cocoapods.org/) and on the [Swift Package Index](https://swiftpackageindex.com/maplibre/maplibre-gl-native-distribution). You can also MapLibre Native iOS [as a dependency to Xcode directly](https://maplibre.org/maplibre-native/ios/latest/documentation/maplibre-native-for-ios/gettingstarted/#Add-MapLibre-Native-as-a-dependency).

MapLibre Native iOS uses UIKit. To intergrate it with an UIKit project, you can use

```swift
class SimpleMap: UIViewController, MLNMapViewDelegate {
var mapView: MLNMapView!

override func viewDidLoad() {
super.viewDidLoad()
mapView = MLNMapView(frame: view.bounds)
mapView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
view.addSubview(mapView)
mapView.delegate = self
}

func mapView(_: MLNMapView, didFinishLoading _: MLNStyle) {
}
}
```

You need to create a wrapper when using SwiftUI.

```swift
import MapLibre

struct SimpleMap: UIViewRepresentable {
func makeUIView(context _: Context) -> MLNMapView {
let mapView = MLNMapView()
return mapView
}

func updateUIView(_: MLNMapView, context _: Context) {}
}
```

You can also use [MapLibreSwiftUI](https://github.com/maplibre/swiftui-dsl), a wrapper around MapLibre Native iOS that offers a declarative API like SwiftUI.

The [iOS Documentation](https://maplibre.org/maplibre-native/ios/latest/documentation/maplibre/) contains many examples and the entire API of the library. You might also want to check out the [MapLibre Native iOS `README.md`](platform/ios/README.md).

## Node.js

There is an [npm package](https://www.npmjs.com/package/@maplibre/maplibre-gl-native) for using MapLibre Native in a Node.js project. The source code of this project [can be found in this repository](https://github.com/maplibre/maplibre-native/tree/main/platform/node).

## Qt

Please check out the [`maplibre/maplibre-native-qt` repository](https://github.com/maplibre/maplibre-native-qt) to learn how to intergrate MapLibre Native with a Qt project.

## Other Platforms

MapLibre Native can also be built on [Linux](platform/linux/README.md), [Windows](platform/windows/README.md) and [macOS](platform/macos/README.md).

## Contributing

> [!NOTE]
> This section is only relevant for people who want to contribute to MapLibre Native.
MapLibre Native has at its core a C++ library. This is where the bulk of development is currently happening.

To get started with the code base, you need to clone the the repository including all its submodules.

All contributors use pull requests from a private fork. [Fork the project](https://github.com/maplibre/maplibre-native/fork). Then run:

```bash
git clone --recurse-submodules [email protected]:<YOUR NAME>/maplibre-native.git
git remote add origin https://github.com/maplibre/maplibre-native.git
```

Check out issues labelled as a [good first issue](https://github.com/maplibre/maplibre-native/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22).

## Core

- [`CONTRIBUTING.md`](CONTRIBUTING.md)
- [MapLibre Native Markdown Book](https://maplibre.org/maplibre-native/docs/book/design/ten-thousand-foot-view.html): architectural notes
- [GitHub Wiki](https://github.com/maplibre/maplibre-native/wiki): low-friction way to share information with the community
- [Core C++ API Documentation](https://maplibre.org/maplibre-native/cpp/api/) (unstable)
- Everyone is free to share knowledge and information on the [wiki](https://github.com/maplibre/maplibre-native/wiki)

See below for the platform-specific `README.md` files.
## Android

## Platforms
Open `platform/android` with Android Studio.

- [⭐️ Android](platform/android/README.md)
- [⭐️ iOS](platform/ios/README.md)
- [GLFW](platform/glfw)
- [Linux](platform/linux/README.md)
- [Node.js](platform/node/README.md)
- [Qt](platform/qt/README.md)
- [Windows](platform/windows/README.md)
- [macOS](platform/macos/README.md)
More information: [`platform/android/DEVELOPING.md`](platform/android/DEVELOPING.md).

Platforms with a ⭐️ are **MapLibre Core Projects** and have a substantial amount of financial resources allocated to them. Learn about the different [project tiers](https://github.com/maplibre/maplibre/blob/main/PROJECT_TIERS.md#project-tiers).
## iOS

## Renderer Modularization & Metal
You need to use [Bazel](https://bazel.build/) to generate an Xcode project. Install [`bazelisk`](https://formulae.brew.sh/formula/bazelisk) (a wrapper that installs the required Bazel version). Next, use:

![image-metal](https://user-images.githubusercontent.com/53421382/214308933-66cd4efb-b5a5-4de3-b4b4-7ed59045a1c3.png)
```bash
bazel run //platform/ios:xcodeproj --@rules_xcodeproj//xcodeproj:extra_common_flags="--//:renderer=metal"
xed platform/ios/MapLibre.xcodeproj
```

MapLibre Native for iOS 6.0.0 with Metal support has been released. See the [news announcement](https://maplibre.org/news/2024-01-19-metal-support-for-maplibre-native-ios-is-here/).

## Contributing
To generate and open the Xcode project.

More information: [`platform/android/CONTRIBUTING.md`](platform/ios/CONTRIBUTING.md).

## Other Platforms

To contribute to MapLibre Native, see [`CONTRIBUTING.md`](CONTRIBUTING.md) and (if applicable) the specific instructions for the platform you want to contribute to.
See [`/platform`](/platform) and navigate to the platform you are interested in for more information.

### Getting Involved
## Getting Involved

Join the `#maplibre-native` Slack channel at OSMUS. Get an invite at https://slack.openstreetmap.us/

Expand Down
3 changes: 2 additions & 1 deletion include/mbgl/actor/scheduler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ class Scheduler {
virtual void waitForEmpty(const util::SimpleIdentity = util::SimpleIdentity::Empty) = 0;

/// Set/Get the current Scheduler for this thread
static Scheduler* GetCurrent();
/// @param init initialize if missing
static Scheduler* GetCurrent(bool init = true);
static void SetCurrent(Scheduler*);

/// Get the scheduler for asynchronous tasks. This method
Expand Down
3 changes: 2 additions & 1 deletion include/mbgl/vulkan/renderer_backend.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@
#include <mbgl/gfx/renderer_backend.hpp>
#include <mbgl/gfx/context.hpp>

#define VULKAN_HPP_DISPATCH_LOADER_DYNAMIC 1

#ifdef _WIN32
#define VK_USE_PLATFORM_WIN32_KHR
#elif defined(__ANDROID__)
#define VK_USE_PLATFORM_ANDROID_KHR
#endif

#define VULKAN_HPP_DISPATCH_LOADER_DYNAMIC 1
#include <vulkan/vulkan.hpp>

#define VMA_VULKAN_VERSION 1000000
Expand Down
3 changes: 3 additions & 0 deletions platform/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Platforms

MapLibre Native Android and MapLibre Native iOS are **MapLibre Core Projects** and have a substantial amount of financial resources allocated to them. Learn about the different [project tiers](https://github.com/maplibre/maplibre/blob/main/PROJECT_TIERS.md#project-tiers).
11 changes: 11 additions & 0 deletions platform/android/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,17 @@

### 🐞 Bug fixes

## 11.5.1

### ✨ Features and improvements

- Add `PropertyFactory.iconPadding(Float)` overload for better backcompat ([#2880](https://github.com/maplibre/maplibre-native/pull/2880)).

### 🐞 Bug fixes

- Android renderThreadManager changed to non static ([#2872](https://github.com/maplibre/maplibre-native/pull/2872)).
- Make sure `Scheduler::GetCurrent()` cannot return a nullptr ([#2887](https://github.com/maplibre/maplibre-native/pull/2887)). This should fix a crash on startup when the library is not initialized on the main thread.

## 11.5.0

### ✨ Features and improvements
Expand Down
2 changes: 1 addition & 1 deletion platform/android/MapLibreAndroid/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION_NAME=11.5.0
VERSION_NAME=11.5.1

# Only build native dependencies for the current ABI
# See https://code.google.com/p/android/issues/detail?id=221098#c20
Expand Down
2 changes: 0 additions & 2 deletions platform/android/MapLibreAndroid/src/cpp/jni_native.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,6 @@ void registerNatives(JavaVM* vm) {

jni::JNIEnv& env = jni::GetEnv(*vm, jni::jni_version_1_6);

// For the FileSource
static mbgl::util::RunLoop mainRunLoop;
FileSource::registerNative(env);

// Basic types
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2047,6 +2047,16 @@ public static PropertyValue<Expression> iconRotate(Expression value) {
return new LayoutPropertyValue<>("icon-rotate", value);
}

/**
* Size of additional area round the icon bounding box used for detecting symbol collisions.
*
* @param value a Float value
* @return property wrapper around Float
*/
public static PropertyValue<Float> iconPadding(Float value) {
return new LayoutPropertyValue<>("icon-padding", value);
}

/**
* Size of additional area round the icon bounding box used for detecting symbol collisions.
*
Expand Down
Loading

0 comments on commit d305bea

Please sign in to comment.