XF 2.0 How to embed a google map

AndreaMarucci

Well-known member
Searched the forum but I've not found a solution.

It seems that there's a BBCode that support google map but if I paste a Map url or an Embed url in the media add, I always get the same error "The specified URL cannot be embedded as media." so I'm asking here if someone has ever embedded a Map in a post and how.

Thanks!
 
not iframe
If I put this

<iframe src="https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d2797.2474285898993!2d9.196082314920222!3d45.48496197910117!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x4786c6ce188a5b8f%3A0xeee4d6ca75b1c355!2sFour+Points+by+Sheraton+Milan+Center!5e0!3m2!1sit!2sit!4v1543530371259" width="600" height="450" frameborder="0" style="border:0" allowfullscreen></iframe>

it's the same
 
I think I need something like
Code:
<div class="map">
{option}
<iframe src="https://www.google.com/maps/embed?SOMEVARIABLESHEREPASSEDBYTHEPASTE></iframe>   
    </div>

<style>.map{text-align: center; width: 100%;}
.map iframe{width: 100%;}</style>
 
I've made it!!!

This is the paste in the message

Code:
[googlemap]!1m18!1m12!1m3!1d2797.2474285898993!2d9.196082314920222!3d45.48496197910117!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x4786c6ce188a5b8f%3A0xeee4d6ca75b1c355!2sFour+Points+by+Sheraton+Milan+Center!5e0!3m2!1sit!2sit!4v1543530371259[/googlemap]

And this is the replacement

Code:
<div align="center" style="margin: 5px 5px 5px 5px;">
     <table class="tborder" cellpadding="6" cellspacing="1" border="0" width="100%">
          <tr>
               <td class="thead" style="text-align:center"><iframe width="100%" height="600" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="https://www.google.com/maps/embed?pb={text}&output=embed"></iframe></td>
          </tr>
     </table>
</div>
 
I've made it!!!

This is the paste in the message

Code:
[googlemap]!1m18!1m12!1m3!1d2797.2474285898993!2d9.196082314920222!3d45.48496197910117!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x4786c6ce188a5b8f%3A0xeee4d6ca75b1c355!2sFour+Points+by+Sheraton+Milan+Center!5e0!3m2!1sit!2sit!4v1543530371259[/googlemap]

And this is the replacement

Code:
<div align="center" style="margin: 5px 5px 5px 5px;">
     <table class="tborder" cellpadding="6" cellspacing="1" border="0" width="100%">
          <tr>
               <td class="thead" style="text-align:center"><iframe width="100%" height="600" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="https://www.google.com/maps/embed?pb={text}&output=embed"></iframe></td>
          </tr>
     </table>
</div>

i just upload a video in XF media but a big file if i see i give you the video link 😀
 
You can make your own Bbcode. Go to

/admin.php?bb-codes/

And create a New Bbcode with this settings:

View attachment 189397

And in the HTML Replacement you paste this:

HTML:
<div align="center" style="margin: 5px 5px 5px 5px;">
     <table class="tborder" cellpadding="6" cellspacing="1" border="0" width="100%">
          <tr>
               <td class="thead" style="text-align:center"><iframe width="100%" height="600" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="https://maps.google.com/maps?q={text}&output=embed"></iframe></td>
          </tr>
     </table>
</div>

For this GOOGLEMAP Bbcode you need also a GoogleMaps API key wich you can get in the Google Developer Tools.

If I have a GoogleMaps API, how to I use it with this code?
 
The link at the bottom of this post


Is what I want to be able to embed, hopefully with BBcode.

Many of my users want to be able to create routes in Google map and then share them in their posts. Can this be done with custom BBcode and will that application need an API?
 
I've made it!!!

This is the paste in the message

Code:
[googlemap]!1m18!1m12!1m3!1d2797.2474285898993!2d9.196082314920222!3d45.48496197910117!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x4786c6ce188a5b8f%3A0xeee4d6ca75b1c355!2sFour+Points+by+Sheraton+Milan+Center!5e0!3m2!1sit!2sit!4v1543530371259[/googlemap]

And this is the replacement

Code:
<div align="center" style="margin: 5px 5px 5px 5px;">
     <table class="tborder" cellpadding="6" cellspacing="1" border="0" width="100%">
          <tr>
               <td class="thead" style="text-align:center"><iframe width="100%" height="600" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="https://www.google.com/maps/embed?pb={text}&output=embed"></iframe></td>
          </tr>
     </table>
</div>

So this worked.

Is there a way to do it without my users having to cut all the iframe stuff of the front and end of the string that is needed between the BBcode tags?
 
Here it is in action for anyone that is interested.

 
So there is a slight issue with this method for embedding Google maps,

Explanation of how to get around the issue

Since it does not use an API, you apparently cannot link to a map that is actually locating a specific "place", like a business.
 
Top Bottom