MyBB Community Forums

Full Version: Google Maps MyCode
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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
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
Updated post #1 with a trip MyCode. Smile
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?
(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.
Well Done!
Its easy enough to do, why don't you add a option for the Longitude and Latitude?
the trip didnt work for me so i edit it a litle
Ex:
[trip]Washington DC/New York[/trip]

Regular Expression :

\[trip\](.*?)/(.*?)\[/trip\]
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>