mirror of
https://github.com/tauri-apps/tauri-docs.git
synced 2026-01-31 00:35:16 +01:00
i18n(ja) Add Japanese translation of geolocation.mdx (#3644)
Co-authored-by: Vitor Ayres <gitkey@virtuaires.com.br>
This commit is contained in:
committed by
GitHub
parent
6fcec03ca8
commit
6a2466a2c3
183
src/content/docs/ja/plugin/geolocation.mdx
Normal file
183
src/content/docs/ja/plugin/geolocation.mdx
Normal file
@@ -0,0 +1,183 @@
|
||||
---
|
||||
title: Geolocation(位置情報)
|
||||
description: デバイスの現在の位置情報(利用可能であれば高度・方位・速度に関する情報も)を取得して追跡します。
|
||||
plugin: geolocation
|
||||
i18nReady: true
|
||||
---
|
||||
|
||||
import PluginLinks from '@components/PluginLinks.astro';
|
||||
import Compatibility from '@components/plugins/Compatibility.astro';
|
||||
|
||||
import { Tabs, TabItem, Steps } from '@astrojs/starlight/components';
|
||||
import CommandTabs from '@components/CommandTabs.astro';
|
||||
import PluginPermissions from '@components/PluginPermissions.astro';
|
||||
import TranslationNote from '@components/i18n/TranslationNote.astro';
|
||||
|
||||
<TranslationNote lang="ja">
|
||||
|
||||
**Plugin 説明内容の英語表記部分について** Plugin の各章は、原文データからページ内容の一部が自動生成されているため、英語表記のままの部分があります。
|
||||
|
||||
</TranslationNote>
|
||||
|
||||
<PluginLinks plugin={frontmatter.plugin} />
|
||||
|
||||
デバイスの現在の位置情報を取得し(利用可能であれば、高度・方位・速度に関する情報も)追跡します。
|
||||
|
||||
## 対応プラットフォーム
|
||||
|
||||
<Compatibility plugin={frontmatter.plugin} />
|
||||
|
||||
## セットアップ
|
||||
|
||||
はじめに、「geolocation 位置情報」プラグインをインストールしてください。
|
||||
|
||||
<Tabs>
|
||||
<TabItem label="自動で設定">
|
||||
|
||||
自分のプロジェクトのパッケージ・マネージャーを使用して依存関係を追加します:
|
||||
|
||||
{' '}
|
||||
|
||||
<CommandTabs
|
||||
npm="npm run tauri add geolocation"
|
||||
yarn="yarn run tauri add geolocation"
|
||||
pnpm="pnpm tauri add geolocation"
|
||||
deno="deno task tauri add geolocation"
|
||||
bun="bun tauri add geolocation"
|
||||
cargo="cargo tauri add geolocation"
|
||||
/>
|
||||
|
||||
</TabItem>
|
||||
<TabItem label="手動で設定">
|
||||
<Steps>
|
||||
|
||||
1. `src-tauri` フォルダで次のコマンドを実行して、このプラグインを `Cargo.toml` 内のプロジェクトの依存関係に追加します:
|
||||
|
||||
```sh frame=none
|
||||
cargo add tauri-plugin-geolocation --target 'cfg(any(target_os = "android", target_os = "ios"))'
|
||||
```
|
||||
|
||||
2. 追加したプラグインを初期化するために `lib.rs` を修正します:
|
||||
|
||||
```rust title="src-tauri/src/lib.rs" ins={5-6}
|
||||
#[cfg_attr(mobile, tauri::mobile_entry_point)]
|
||||
pub fn run() {
|
||||
tauri::Builder::default()
|
||||
.setup(|app| {
|
||||
#[cfg(mobile)]
|
||||
app.handle().plugin(tauri_plugin_geolocation::init());
|
||||
Ok(())
|
||||
})
|
||||
.run(tauri::generate_context!())
|
||||
.expect("error while running tauri application");
|
||||
}
|
||||
```
|
||||
|
||||
3. お好みの JavaScript パッケージ・マネージャーを使用して、「JavaScript Guest」バインディングをインストールします:
|
||||
|
||||
<CommandTabs
|
||||
npm="npm install @tauri-apps/plugin-geolocation"
|
||||
yarn="yarn add @tauri-apps/plugin-geolocation"
|
||||
pnpm="pnpm add @tauri-apps/plugin-geolocation"
|
||||
deno="deno add npm:@tauri-apps/plugin-geolocation"
|
||||
bun="bun add @tauri-apps/plugin-geolocation"
|
||||
/>
|
||||
|
||||
</Steps>
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
## 設定
|
||||
|
||||
### iOS
|
||||
|
||||
Apple は、位置情報に関して Info.plist にプライバシー関連の記述を行なうことを義務付けています。これには、アプリが位置情報にアクセスする必要がある理由を記述する必要があります。以下に記述例を示します:
|
||||
|
||||
```xml {6-7}
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>NSLocationWhenInUseUsageDescription</key>
|
||||
<string>Required to do XY</string>
|
||||
</dict>
|
||||
</plist>
|
||||
```
|
||||
|
||||
### Android
|
||||
|
||||
このプラグインは、`AndroidManifest.xml` ファイルに以下のアクセス権限を自動的に追加します:
|
||||
|
||||
```xml
|
||||
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
|
||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
||||
```
|
||||
|
||||
あなたのアプリが GPS 機能を必要とする場合は、`AndroidManifest.xml` ファイルに次の記述を追加する必要があります:
|
||||
|
||||
```xml
|
||||
<uses-feature android:name="android.hardware.location.gps" android:required="true" />
|
||||
```
|
||||
|
||||
Google Play ストアは、GPS 機能を有していないデバイスにこのアプリを表示するかどうかを判定するために、このプロパティ値を使用します。
|
||||
|
||||
## 使用法
|
||||
|
||||
「geolocation」プラグインは JavaScript で利用できます。
|
||||
|
||||
```javascript
|
||||
import {
|
||||
checkPermissions,
|
||||
requestPermissions,
|
||||
getCurrentPosition,
|
||||
watchPosition,
|
||||
} from '@tauri-apps/plugin-geolocation';
|
||||
|
||||
let permissions = await checkPermissions();
|
||||
if (
|
||||
permissions.location === 'prompt' ||
|
||||
permissions.location === 'prompt-with-rationale'
|
||||
) {
|
||||
permissions = await requestPermissions(['location']);
|
||||
}
|
||||
|
||||
if (permissions.location === 'granted') {
|
||||
const pos = await getCurrentPosition();
|
||||
|
||||
await watchPosition(
|
||||
{ enableHighAccuracy: true, timeout: 10000, maximumAge: 0 },
|
||||
(pos) => {
|
||||
console.log(pos);
|
||||
}
|
||||
);
|
||||
}
|
||||
```
|
||||
|
||||
## アクセス権限 Permissions
|
||||
|
||||
デフォルトでは、潜在的に危険なプラグイン・コマンドとそのスコープ(有効範囲)はすべてブロックされており、アクセスできません。これらを有効にするには、`capabilities` 設定でアクセス権限を変更する必要があります。
|
||||
|
||||
詳細については「[セキュリティ・レベル Capabilities](/ja/security/capabilities/)」の章を参照してください。また、プラグインのアクセス権限を設定するには「[プライグン・アクセス権の使用](/ja/learn/security/using-plugin-permissions/)」の章のステップ・バイ・ステップ・ガイドを参照してください。
|
||||
|
||||
```json title="src-tauri/capabilities/mobile.json" ins={7-11}
|
||||
{
|
||||
"$schema": "../gen/schemas/mobile-schema.json",
|
||||
"identifier": "mobile-capability",
|
||||
"windows": ["main"],
|
||||
"platforms": ["iOS", "android"],
|
||||
"permissions": [
|
||||
"core:default",
|
||||
"geolocation:allow-check-permissions",
|
||||
"geolocation:allow-request-permissions",
|
||||
"geolocation:allow-get-current-position",
|
||||
"geolocation:allow-watch-position"
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
<PluginPermissions plugin={frontmatter.plugin} />
|
||||
|
||||
<div style="text-align: right;">
|
||||
【※ この日本語版は、「Nov 21, 2025 英語版」に基づいています】
|
||||
</div>
|
||||
Reference in New Issue
Block a user