This plugin provides APIs for displaying and interacting with maps in Tauri applications, supporting iOS platforms.
Install the Core plugin by adding the following to your Cargo.toml file:
[dependencies]
tauri-plugin-map-display = { git = "https://github.com/inkibra/tauri-plugins", tag = "@inkibra/tauri-plugin-map-display@VERSION", package="tauri-plugin-map-display" }Before installing the JavaScript bindings, you need to configure npm to use the GitHub Packages registry for the @inkibra scope. Run the following command:
npm config set @inkibra:registry https://npm.pkg.github.comFor yarn users:
yarn config set @inkibra:registry https://npm.pkg.github.comFor pnpm users:
pnpm config set @inkibra:registry https://npm.pkg.github.comAfter setting the registry, you can install the JavaScript Guest bindings using your preferred JavaScript package manager:
npm add @inkibra/tauri-plugin-map-display
# or
yarn add @inkibra/tauri-plugin-map-display
# or
pnpm add @inkibra/tauri-plugin-map-displayNote: If you're using a monorepo with Lerna, make sure to set the registry in your root .npmrc file or use Lerna's scoped registry configuration.
First, you need to register the core plugin with Tauri:
fn main() {
tauri::Builder::default()
.plugin(tauri_plugin_map_display::init())
.run(tauri::generate_context!())
.expect("error while running tauri application");
}Afterward, you can use the plugin in your JavaScript code to interact with maps.
Based on the provided Swift code, the plugin likely supports the following functions:
-
showMap(options: ShowMapRequest): Promise<ShowMapResponse>- Displays a map with the specified options.
-
hideMap(): Promise<HideMapResponse>- Hides the currently displayed map.
-
setRegion(options: SetRegionRequest): Promise<SetRegionResponse>- Sets the region of the map to display.
- Ensure you have set up your Xcode project correctly.
- The plugin uses
MapKit, so make sure your app has the necessary permissions and capabilities enabled in Xcode.
Here's a basic example of how to use the plugin:
import { showMap, setRegion } from '@inkibra/tauri-plugin-map-display';
// Show a map
const showMapResult = await showMap({
frame: { x: 0, y: 0, width: 300, height: 300 },
mapType: 'standard',
showsUserLocation: true
});
if (showMapResult.success) {
console.log('Map displayed successfully');
// Set the map region
const setRegionResult = await setRegion({
region: {
center: { latitude: 37.7749, longitude: -122.4194 },
span: { latitudeDelta: 0.1, longitudeDelta: 0.1 }
}
});
if (setRegionResult.success) {
console.log('Map region set successfully');
}
}This plugin follows Tauri's security recommendations and implements the following features:
- Permission-based access to plugin functionality
- Sandboxed execution on supported platforms
For more details, check the permissions folder in the plugin's repository.
We welcome contributions to this plugin! Please feel free to submit issues and pull requests.
This plugin is licensed under either of:
- Apache License, Version 2.0
- MIT license
at your option.
This plugin is maintained by the Inkibra team and the Tauri community.