====== maplink Plugin ======
---- plugin ----
description: Links an address or other search text directly to Google maps
author : chlw
email : none
type : Syntax
lastupdate : 2021-05-01
compatible : Adora Belle, Weatherwax, Binky, Hogfather
depends :
conflicts :
similar : anchor
tags : links, maps
downloadurl: http://stuff.eldach.ch/stuff/dokuwiki/maplink/maplink.zip
bugtracker :
sourcerepo :
donationurl:
screenshot_img :
----
This plugin links an address or any other string directly to Google maps. This can be helpful if you want to provide a link to Google maps without embedding the map.
This plugin is based on the Plugins [[plugin:anchor|anchor]] and [[plugin:icalendar|iCalendar]]. I just took parts of those plugins an merged them together. So all the kudos go to those authors!
===== Installation =====
This plugin is very simple (contains only one file) and I'm not familiar with the repository-stuff (git etc.). Therefore I'm just going to include the source code here as well (e.g. in case the link to the download is broken etc.).
The following code should be copied in the file "lib/plugins/maplink/syntax.php", that means:
- Create a directory "maplink" in the "/lib/plugins"-Directory of your Dokuwiki Installation
- Create a file containing the code below and name it "syntax.php"
- Put this file in the directory, you created in step 1 (lib/plugins/maplink/)
'chlw; based on work by Eli Fenton (Anchor Plugin) and J. Drost-Tenfelde (iCalendar Plugin)', 'name' => 'maplink', 'url' => 'http://dokuwiki.org/plugin:maplink');}
function connectTo($mode){
$this->Lexer->addSpecialPattern('\{\{maplink:[^}]*\}\}', $mode, 'plugin_maplink');
}
function handle($match, $state, $pos, Doku_Handler $handler) {
return explode(':', substr($match, strlen('{{maplink:'), -2));
}
function render($format, Doku_Renderer $renderer, $data) {
$renderer->doc .= '' .htmlspecialchars($data[1]) . '';
}
}
You might want to delete the code "target="_blank"
if the map should open in the same window.
===== Examples/Usage =====
Here's how you create a link:
{{maplink:string_to_search:text_to_display}}
The string_to_search part is what Google maps should search for (can be an address or any other string, see examples below). The text_to_display part is what the user sees as the clickable text.
=== Examples ===
The following code genereates a clickable link with text:
{{maplink:15010 NE 36th Street, Microsoft Campus, Redmond, WA 98052:This is a link to the Microsoft Visitor Center}}
\\ \\
The same link with the address as text:
{{maplink:15010 NE 36th Street, Microsoft Campus, Redmond, WA 98052:15010 NE 36th Street, Microsoft Campus, Redmond, WA 98052}}
\\ \\
You might want to search for other strings (e.g. names of places, hotels, attractions etc.) than plain addresses:
{{maplink:The Peninsula Hotel, Bangkok:Five Star Hotel in Thailand}}
\\ \\
Tip: You might want to include the words "route planner, Routenplaner, Anfahrt" or similar in your language in your search. Depending on your actual position Google Maps opens directly in the route planner mode (which is a bit scary... ;-):
{{maplink:The Peninsula Hotel route planner, Bangkok:Five Star Hotel in Thailand}}
\\ \\
=== Screenshots ===
{{http://stuff.eldach.ch/stuff/dokuwiki/maplink/snap_001.gif?200x200&direct |Link in Action}}
{{http://stuff.eldach.ch/stuff/dokuwiki/maplink/snap_002.gif?200x200&direct |Example Code}}
\\ \\ \\
===== Configuration and Settings =====
The plugin has no configuration or settings. You might want to delete the code "target="_blank"
if you want the map to open in the same window (instead of a new one).
===== Development =====
This is my first plugin and I'm not really familiar with programming, so I'm quite sure someone can improve it.
=== Change Log ===
* **2021-05-01**
* Release 2.0: Made some code changes to work with Dokuwiki Release "Hogfather". Still not really familiar with programming...
* **2013-12-26**
* Initial release
=== Known Bugs and Issues ===
None, so far.
=== ToDo / Wish List / Questions===
* Could this be coded in a more clever way?
* Does this code really cover all possible cases? I tried it with some Thai text and, no surprise, it did not work.
* The link does not appear on the same line but on a separate next line / paragraph if you have a code like:\\ Location of the fiesta: {{maplink:Playa del Sol Hotel Cancun Mexico:Playa del Sol -- my favourite place}}
Any hints on that...?
===== Discussion =====
Please discuss the plugin here.