Google Maps MyCode
#1
This is a very simple MyCode but useful when you want position of a location (party, meeting, event, ...) inline of posts and calender events.

Title
Map
(or whatever you like)

Regular Expression
\[map\](.*?)\[/map\]

Replacement
<object data="http://maps.google.com/?q=$1&amp;output=embed" type="text/html" width="640" height="480" class="map">
<a href="http://maps.google.com/?q=$1">$1</a>
</object>

Example
[map]1600 Amphitheatre Parkway, CA 94043[/map]

Use CSS class map to style it (maybe as block element with border, ...).



If you want to show a route between 2 locations you have to create a second MyCode:

Title
Trip
(or whatever you like)

Regular Expression
\[map\](.*?)\[/map\][\s]*\[map\](.*?)\[/map\]

Replacement
<object data="http://maps.google.com/?saddr=$1&amp;daddr=$2&amp;output=embed" type="text/html" width="640" height="480" class="map">
<a href="http://maps.google.com/?saddr=$1&amp;daddr=$2">$1 - $2</a>
</object>

Parse Order
Have to be a smaller parse order value than the single map MyCode!

Example
[map]Washington DC[/map]
[map]New York[/map]

Whenever someone uses 2 [map] MyCodes in a row (it can be 'nothing', line breaks, spaces and/or tab stops between the MyCodes) a route will be shown instead of 2 single maps. Smile


Attached Files Thumbnail(s)
       
Reply
#2
I am gonna try and use this at my local area Wink
Also you can use the coordinate from Google. Not only the street name
Hello, Welcome to MyBB Indonesia to get local support
My 'Simple' Unique Plugin here Smile
Reply
#3
Updated post #1 with a trip MyCode. Smile
Reply
#4
Very nice, Thanks for sharing Smile

How do you get the coordinates from Google?
Would it be possible to add a "View Larger Map" link just below the map which would open in a new page?
[Image: forumlogo.png]
Reply
#5
(2011-05-25, 01:35 PM)RArch Wrote: Would it be possible to add a "View Larger Map" link just below the map which would open in a new page?

Just add this above or below the <object> tag in MyCode replacement:

<a href="http://maps.google.com/?q=$1">$1</a>

Just a simple link to Google Maps.
Reply
#6
Well Done!
Reply
#7
Its easy enough to do, why don't you add a option for the Longitude and Latitude?
Reply
#8
the trip didnt work for me so i edit it a litle
Ex:
[trip]Washington DC/New York[/trip]

Regular Expression :

\[trip\](.*?)/(.*?)\[/trip\]
Reply
#9
Thanks for the code, querschlaeger. I was able to use it and even after all the years it's still working. Almost. I had to only add a "s" into the link. Code I'm using is:

Tittle:


Maps


Regular Expression:

\[map\](.*?)\[/map\]


Replacement:
<object data="https://maps.google.co.uk/?q=$1&amp;output=embed" type="text/html" width="640" height="480" class="map">
<a href="https://maps.google.co.uk/?q=$1">$1</a>
</object>
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)