Accepts
URLs and Map Links
COMMENT
將目前 Apple 地圖 或 Google 地圖 中選擇的地點,直接切換到另一個地圖上並開啟導航路線。
Switch current selected place and show directions between Apple Maps and Google Maps, you can change this shortcut’s name to “Switch Maps and Show Directions” for English users.
Jason Nonlinear
https://www.youtube.com/c/JasonNonlinear
v2.2
MIT License
TEXT
Split
Shortcut Input
by
New Lines

Split Text
SCRIPTING
Get
Last Item
from
分開文字

Item from List
WEB
Expand
來自列表的項目

Expanded URL
VARIABLES
Set variable
url
to
已展開的URL
TEXT
url

Text
SCRIPTING
If
文字
contains
google.com
TEXT
false

Text
VARIABLES
Set variable
isCoordinates
to
文字
URL
Get
Scheme
from
已展開的URL

Component of URL
SCRIPTING
Get
Value
for
q
in
URL組件

Dictionary Value
VARIABLES
Set variable
location
to
辭典值
TEXT
Split
辭典值
by
Custom
,

Split Text
SCRIPTING
Count
Items
in
分開文字

Count
SCRIPTING
If
計數
is
2
SCRIPTING
Get
Item At Index
1
from
分開文字

Item from List
TEXT
Match
^\d*\.?\d+$
in
來自列表的項目

Matches
SCRIPTING
If
符合項目
has any value
SCRIPTING
Get
Item At Index
2
from
分開文字

Item from List
TEXT
Match
^\d*\.?\d+$
in
來自列表的項目

Matches
SCRIPTING
If
符合項目
has any value
TEXT
true

Text
VARIABLES
Set variable
isCoordinates
to
文字
SCRIPTING
End If

If Result
SCRIPTING
End If

If Result
SCRIPTING
End If

If Result
SCRIPTING
If
isCoordinates
is
false
TEXT
false

Text
VARIABLES
Set variable
twAddr
to
文字
LIST

List
TEXT
location

Text
SCRIPTING
Repeat with each item in
列表

Repeat Results
SCRIPTING
If
twAddr
is
false
TEXT
Repeat Item

Text
SCRIPTING
If
文字
contains
文字
VARIABLES
Set variable
twAddr
to
文字
SCRIPTING
End If

If Result
SCRIPTING
End If

If Result
SCRIPTING
End Repeat

Repeat Results
TEXT
twAddr

Text
SCRIPTING
If
文字
is not
false
COMMENT
特別處理台灣地址
MAPS
Get addresses from
location

Addresses
DOCUMENTS
Replace
\n
with
in
地址

Updated Text
SCRIPTING
URL
Encode
已更新的文字

URL Encoded Text
TEXT
https://www.google.com/maps?q=
URL編碼文字

Text
VARIABLES
Set variable
url
to
文字
SCRIPTING
End If

If Result
SCRIPTING
End If

If Result
MAPS
Show
Driving
directions to
url
SCRIPTING
Otherwise
URL
Get
Scheme
from
已展開的URL

Component of URL
SCRIPTING
Get
Value
for
address
in
URL組件

Dictionary Value
VARIABLES
Set variable
location
to
辭典值
SCRIPTING
If
location
does not have any value
SCRIPTING
Get
Value
for
ll
in
URL組件

Dictionary Value
VARIABLES
Add
辭典值
to
location
TEXT
location

Text
MAPS
Show
Driving
directions to
文字
SCRIPTING
Otherwise
COMMENT
去除台灣地址開頭的郵遞區號,避免誤判
TEXT
Match
^[\d]+台灣
in
location

Matches
SCRIPTING
If
符合項目
has any value
DOCUMENTS
Replace
^[\d]+
with
World
in
location

Updated Text
VARIABLES
Set variable
location
to
已更新的文字
SCRIPTING
End If

If Result
SCRIPTING
Get
Value
for
q
in
URL組件

Dictionary Value
TEXT
辭典值
,
location

Text
SCRIPTING
URL
Encode
文字

URL Encoded Text
TEXT
http://maps.google.com/?q=
URL編碼文字

Text
MAPS
Show
Driving
directions to
文字
SCRIPTING
End If

If Result
SCRIPTING
End If

If Result