Organic Maps
Organic Maps 是一款离线地图与导航应用。Protocol Launcher 可以生成 Organic Maps deep links。
使用方式
这个库有两种使用方式:
- On-Demand 从子路径导入,支持 tree-shaking,能让产物更小。
- Full Import 从根包导入,适合快速脚本或演示,但会包含全部 app 模块。
生产构建建议选择 On-Demand;快速脚本或 demo 可以选择 Full Import。
选择安装方式
URL Methods
此模块对齐 Organic Maps 官方 API 页中记录的 Organic Maps 链接:shared-point links、map?v=1、route?v=1、v2 dir 和 nav、search、Organic Maps 支持的 geo: 示例、Android intent 启动 URI,以及 crosshair 位置选择器。
同一页面也列出了 MAPS.ME、Google Maps、OpenStreetMap、2GIS 兼容链接和可下载的 KML/KMZ/GPX 文件。那些不是 Organic Maps URL helper,所以本模块不会生成这些链接。
Show Shared Point
通过短码路径显示 Organic Maps 共享点,并可附带 title。
import { showSharedPoint } from 'protocol-launcher/organic-maps'
const url = showSharedPoint({
code: 'o4B4pYZsRs',
title: 'Zoo_Zürich',
})Show Map
使用官方 map?v=1 链接在地图上显示一个或多个点。
import { showMap } from 'protocol-launcher/organic-maps'
const url = showMap({
points: [
{ ll: '22.17319,-159.65687', title: 'Kalalau Camping' },
{ ll: '22.17168,-159.66096', title: 'Dream Beach' },
{ ll: '22.17182,-159.65776' },
],
})Route
使用 v1 API 构建路线,支持官方记录的 vehicle、pedestrian、bicycle 和 transit 类型。
import { route } from 'protocol-launcher/organic-maps'
const url = route({
start: { ll: '50.183933,8.942871', address: 'Start Point' },
destination: { ll: '49.998912,8.278198', address: 'EndPoint' },
type: 'vehicle',
})Directions
使用 v2/dir 构建 v2 多站点路线。
import { directions } from 'protocol-launcher/organic-maps'
const url = directions({
origin: '52.5200,13.4050',
originName: 'Warehouse Berlin',
destination: '52.5163,13.3777',
destinationName: 'Customer',
waypoints: ['52.5304,13.3850', '52.5450,13.3920'],
waypointNames: ['Pickup 1', 'Pickup 2'],
mode: 'drive',
})Navigate
使用 v2/nav 启动 v2 导航,并携带 waypoint callbacks 和 route completion callback。
import { navigate } from 'protocol-launcher/organic-maps'
const url = navigate({
origin: 'currentLocation',
destination: '52.5163,13.3777',
destinationName: 'Customer',
waypoints: ['52.5304,13.3850', '52.5450,13.3920'],
waypointCallbacks: ['delivery://stop/1', 'delivery://stop/2'],
callback: 'delivery://route/complete',
mode: 'drive',
})Search
在 Organic Maps 中搜索,并可传入中心坐标和 locale。
import { search } from 'protocol-launcher/organic-maps'
const url = search({
cll: '47.3813,8.5889',
locale: 'de',
query: 'Mame',
})Geo
生成 Organic Maps 支持的 geo: URI。
import { geo } from 'protocol-launcher/organic-maps'
const url = geo({
coordinates: '35.341714,33.32231',
title: 'Custom Title',
})Crosshair
使用官方 crosshair 链接打开 Organic Maps 位置选择器。
import { crosshair } from 'protocol-launcher/organic-maps'
const url = crosshair({
cll: '47.3813,8.5889',
appname: 'Google Maps',
})Android Intent
生成官方记录的 Android intent URI,用于启动 Organic Maps。
import { androidIntent } from 'protocol-launcher/organic-maps'
const url = androidIntent({
packageName: 'app.organicmaps',
})生成的 URL
showSharedPoint({ code: 'o4B4pYZsRs', title: 'Zoo_Zürich' })
// => 'om://o4B4pYZsRs/Zoo_Zürich'
showMap({
points: [
{ ll: '22.17319,-159.65687', title: 'Kalalau Camping' },
{ ll: '22.17168,-159.66096', title: 'Dream Beach' },
{ ll: '22.17182,-159.65776' },
],
})
// => 'om://map?v=1&ll=22.17319,-159.65687&n=Kalalau%20Camping&ll=22.17168,-159.66096&n=Dream%20Beach&ll=22.17182,-159.65776'
route({
start: { ll: '50.183933,8.942871', address: 'Start Point' },
destination: { ll: '49.998912,8.278198', address: 'EndPoint' },
type: 'vehicle',
})
// => 'om://route?v=1&sll=50.183933,8.942871&saddr=Start%20Point&dll=49.998912,8.278198&daddr=EndPoint&type=vehicle'
directions({
origin: '52.5200,13.4050',
originName: 'Warehouse Berlin',
destination: '52.5163,13.3777',
destinationName: 'Customer',
waypoints: ['52.5304,13.3850', '52.5450,13.3920'],
waypointNames: ['Pickup 1', 'Pickup 2'],
mode: 'drive',
})
// => 'om://v2/dir?origin=52.5200,13.4050&origin_name=Warehouse%20Berlin&destination=52.5163,13.3777&destination_name=Customer&waypoints=52.5304,13.3850|52.5450,13.3920&waypoint_names=Pickup%201|Pickup%202&mode=drive'
navigate({
origin: 'currentLocation',
destination: '52.5163,13.3777',
destinationName: 'Customer',
waypoints: ['52.5304,13.3850', '52.5450,13.3920'],
waypointCallbacks: ['delivery://stop/1', 'delivery://stop/2'],
callback: 'delivery://route/complete',
mode: 'drive',
})
// => 'om://v2/nav?origin=currentLocation&destination=52.5163,13.3777&destination_name=Customer&waypoints=52.5304,13.3850|52.5450,13.3920&waypoint_callbacks=delivery%3A%2F%2Fstop%2F1|delivery%3A%2F%2Fstop%2F2&callback=delivery%3A%2F%2Froute%2Fcomplete&mode=drive'
search({ cll: '47.3813,8.5889', locale: 'de', query: 'Mame' })
// => 'om://search?cll=47.3813,8.5889&locale=de&query=Mame'
geo({ coordinates: '35.341714,33.32231', title: 'Custom Title' })
// => 'geo:35.341714,33.32231(Custom%20Title)'
crosshair({ cll: '47.3813,8.5889', appname: 'Google Maps' })
// => 'om://crosshair?cll=47.3813,8.5889&appname=Google%20Maps'
androidIntent({ packageName: 'app.organicmaps' })
// => 'intent://#Intent;package=app.organicmaps;scheme=om;end;'