Go Back   vb.org Archive > vBulletin Modifications > Archive > vB.org Archives > vBulletin 3.7 > vBulletin 3.7 Add-ons
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools
Google maps BBCode Details »»
Google maps BBCode
Version: 1.1, by oasi oasi is offline
Developer Last Online: Dec 2008 Show Printable Version Email this Page

Category: BB Code Enhancements - Version: 3.7.x Rating:
Released: 10-15-2008 Last Update: Never Installs: 86
Re-useable Code Translations Is in Beta Stage  
No support by the author.

Hi all

I've made a Custom BBcode to be able to insert any kind of google map into the forum posts, so the Plugins I tried were'nt working as we expected.

I post the code, I hope it can be useful for anyone.

Security problems, improvements and tunning will be apreciated...

I used the tag [gmap], and inside you have to copy the code for the HTML inclusion you can copy when you click the link icon in the map:



Code:
<script type="text/javascript">
function ckURL()
  {   if ((u.indexOf("http://")!=u.lastIndexOf("http://"))||u.lastIndexOf("http://")!=0){return false;}
      if (u.indexOf('"')>=0) {return false;}
      if (u.indexOf("http://maps.google")!=0){return false;}
      return true;
  }

t='';incr=0;t_i="{param}";
t_n_q=t_i.replace(/&quot;/g,'"');

if(t_n_q.indexOf("91;url")>0)
{ if(t_n_q.indexOf('91;url="')>0){t=t_n_q.substr(t_n_q.indexOf('91;url="')+8,t_n_q.length);t_n_q='';}
  if(t_n_q.indexOf('91;url=')>0) {t=t_n_q.substr(t_n_q.indexOf('91;url=')+7,t_n_q.length);t_n_q='';a=t.replace(/93;/g,'"');t=a;incr=2;}
  if(t_n_q.indexOf('91;url')>0)  {if (t_n_q.indexOf('93;')==(t_n_q.indexOf('91;url')+8)){t=t_n_q.substr(t_n_q.indexOf('91;url')+11,t_n_q.length);a=t.replace(/91;/g,'"');t=a;}}
}
else
{ t=t_n_q.substr(t_n_q.indexOf('src="')+5,t_n_q.length);}
u=t.substr(0,t.indexOf('"')-incr);
up=u.replace(/amp;/g,'');u=up;

if (ckURL())
{ document.write('<iframe width="640" height="480" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="'+u+'"></iframe>');}
else
{document.write("<p><b>Wrong map URL, edit the post to change it.</b></p>Reload the page when finished to check if correct.");}
</script>
The others settings for the BBCode are:

Use {option}: -> No
Remove Tag If Empty -> Yes
Disable BB Code Within This BB Code -> Yes
Disable Smilies Within This BB Code -> Yes
Disable Word Wrapping Within This BB Code ->Yes

Please, mark as installed if it worked and you are using it.

Hope it helps!

Show Your Support

  • This modification may not be copied, reproduced or published elsewhere without author's permission.

Comments
  #52  
Old 10-24-2008, 11:45 AM
oasi oasi is offline
 
Join Date: Mar 2008
Location: Tarragona
Posts: 31
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I'm not been able to reproduce the link stuff you mentioned, but This version could solve this stuff and the related with the &amp;

Please, try it and let me know...

Code:
<script type="text/javascript">
function checkURL()
  {
      if ((url.indexOf("http://")!=url.lastIndexOf("http://"))||url.lastIndexOf("http://")!=0){return false;}
      if (url.indexOf('"')>=0) {return false;}
      if (url.indexOf("http://maps.google")!=0){return false;}
      return true
  }

tot='';
tot_ini='{param}';
tot_no_amp=tot_ini.replace(/&amp;/g,'&');
tot_no_quo=tot_no_amp.replace(/&quot;/g,'"');
tot=tot_no_quo.substr(tot_no_quo.indexOf('marginwidth="0" src="')+21,tot_no_quo.length);
url=tot.substr(0,tot.indexOf('"'));
urlp=url.replace(/amp;/g,'');
url=urlp;

if (checkURL())
{   
    document.write('<iframe width="640" height="480" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="'+url+'"></iframe>');
}
else
{
document.write("<p><b>WRONG URL</b></p>Recorda que cal enganxar el contingut del camp que indica que es per enganxar en una web.<br />Un cop arreglat el post, has de recarregar la plana per poder veure si ha funcionat.");
}
</script>
If this fails, and the error message appears, please view source on the document and paste here the value for the variable tot_ini ( Right click on document, View source, search tot_ini)

Thanks
Reply With Quote
  #53  
Old 10-24-2008, 05:42 PM
Leo Brazil's Avatar
Leo Brazil Leo Brazil is offline
 
Join Date: Dec 2007
Location: Brazil
Posts: 485
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hi oasi,

Nothing changed so far, let's see.

This is the link I'm using for tests already with gmap tags

[gmap]<iframe width="425" height="350" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.com/maps?f=q&amp;hl=pt-BR&amp;q=Liberdade,+S%C3%A3o+Paulo+-+SP,+Brasil&amp;ie=UTF8&amp;cd=1&amp;geocode=FdJhm P4de304_Q&amp;ll=-23.558323,-46.62529&amp;spn=0.036583,0.054932&amp;z=14&amp;iw loc=addr&amp;output=embed&amp;s=AARTsJrSb_gFa1Ssu_ 1wwOFTDbl5gJKezg"></iframe><br /><small><a href="http://maps.google.com/maps?f=q&amp;hl=pt-BR&amp;q=Liberdade,+S%C3%A3o+Paulo+-+SP,+Brasil&amp;ie=UTF8&amp;cd=1&amp;geocode=FdJhm P4de304_Q&amp;ll=-23.558323,-46.62529&amp;spn=0.036583,0.054932&amp;z=14&amp;iw loc=addr&amp;source=embed" style="color:#0000FF;text-align:left">Exibir mapa ampliado</a></small>[/gmap]


And this is the source code of my page after I post it.


Code:
		<!-- message -->
		<div id="post_message_26"><font face="Arial"><font size="2"><script type="text/javascript">
function checkURL()
  {
      if ((url.indexOf("http://")!=url.lastIndexOf("http://"))||url.lastIndexOf("http://")!=0){return false;}
      if (url.indexOf('"')>=0) {return false;}
      if (url.indexOf("http://maps.google")!=0){return false;}
      return true
  }

tot='';
tot_ini='&lt;iframe width=&quot;425&quot; height=&quot;350&quot; frameborder=&quot;0&quot; scrolling=&quot;no&quot; marginheight=&quot;0&quot; marginwidth=&quot;0&quot; src=&quot;[url=&quot;http://maps.google.com/maps?f=q&amp;amp;hl=pt-BR&amp;amp;q=Liberdade,+S%C3%A3o+Paulo+-+SP,+Brasil&amp;amp;ie=UTF8&amp;amp;cd=1&amp;amp;geocode=FdJhmP4de304_Q&amp;amp;ll=-23.558323,-46.62529&amp;amp;spn=0.036583,0.054932&amp;amp;z=14&amp;amp;iwloc=addr&amp;amp;output=embed&amp;amp;s=AARTsJrSb_gFa1Ssu_1wwOFTDbl5gJKezg&quot;&gt;&lt;/iframe&gt;&lt;br&quot;][color=#0000ff]http://maps.google.com/maps?f=q&amp;amp;hl=pt-BR&amp;amp;q=Liberdade,+S%C3%A3o+Paulo+-+SP,+Brasil&amp;amp;ie=UTF8&amp;amp;cd=1&amp;amp;geocode=FdJhmP4de304_Q&amp;amp;ll=-23.558323,-46.62529&amp;amp;spn=0.036583,0.054932&amp;amp;z=14&amp;amp;iwloc=addr&amp;amp;output=embed&amp;amp;s=AARTsJrSb_gFa1Ssu_1wwOFTDbl5gJKezg&quot;&gt;&lt;/iframe&gt;&lt;br[/color][/url] /&gt;&lt;small&gt;&lt;a href=&quot;[url=&quot;http://maps.google.com/maps?f=q&amp;amp;hl=pt-BR&amp;amp;q=Liberdade,+S%C3%A3o+Paulo+-+SP,+Brasil&amp;amp;ie=UTF8&amp;amp;cd=1&amp;amp;geocode=FdJhmP4de304_Q&amp;amp;ll=-23.558323,-46.62529&amp;amp;spn=0.036583,0.054932&amp;amp;z=14&amp;amp;iwloc=addr&amp;amp;source=embed&quot;][color=#0000ff]http://maps.google.com/maps?f=q&amp;amp;hl=pt-BR&amp;amp;q=Liberdade,+S%C3%A3o+Paulo+-+SP,+Brasil&amp;amp;ie=UTF8&amp;amp;cd=1&amp;amp;geocode=FdJhmP4de304_Q&amp;amp;ll=-23.558323,-46.62529&amp;amp;spn=0.036583,0.054932&amp;amp;z=14&amp;amp;iwloc=addr&amp;amp;source=embed[/color][/url]&quot; style=&quot;color:#0000FF;text-align:left&quot;&gt;Exibir mapa ampliado&lt;/a&gt;&lt;/small&gt;';
tot_no_amp=tot_ini.replace(/&amp;/g,'&amp;');
tot_no_quo=tot_no_amp.replace(/&quot;/g,'"');
tot=tot_no_quo.substr(tot_no_quo.indexOf('marginwidth="0" src="')+21,tot_no_quo.length);
url=tot.substr(0,tot.indexOf('"'));
urlp=url.replace(/amp;/g,'');
url=urlp;

if (checkURL())
{   
    document.write('<iframe width="640" height="480" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="'+url+'"></iframe>');
}
else
{
document.write("<p><b>WRONG URL</b></p>Recorda que cal enganxar el contingut del camp que indica que es per enganxar en una web.<br />Un cop arreglat el post, has de recarregar la plana per poder veure si ha funcionat.");
}
</script></font></font></div>
		<!-- / message -->
The problem is I must use WYSIWYG editor on my board and when I paste the Google Maps links the editor parses a lot of thing with braking the pure link itself.
Reply With Quote
  #54  
Old 10-24-2008, 07:17 PM
MediaHound MediaHound is offline
 
Join Date: May 2004
Location: Florida
Posts: 165
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Subscribing to thread, this is a wonderful hack, hope the "Wrong map URL, edit the post to change it." errors get fixed as that's a problem for me as well.
Reply With Quote
  #55  
Old 10-24-2008, 08:14 PM
tintin74 tintin74 is offline
 
Join Date: Jul 2007
Posts: 49
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

First of all a big thank you to Oasi for studing on this very useful mod. I'm search for it for a long time!

I've tried to embed several Google maps without any problem but now I want to embed this kind of map , but I've had negative result.

This is the web page from where I have take the iframe link:

Code:
http://maps.google.com/maps?f=d&saddr=Bagolino+BS&daddr=darfo+boario+to:endine+to:Frazione+Rigosa%2FSP28+to:san+pellegrino+terme+to:sant%27omobono+imagna+to:valcava+to:Como+CO&hl=it&geocode=%3B%3B%3BFR7ougId7q6UAA%3B%3B%3B%3B&mra=ls&via=3&sll=45.702343,9.813538&sspn=0.895773,1.757813&ie=UTF8&ll=45.844108,9.775085&spn=0.893499,1.757813&t=p&z=9
As you could see, it doesn't work.

Could you solve also this issue, please?

Thank you

Regards

Tintin
Reply With Quote
  #56  
Old 10-27-2008, 07:02 AM
oasi oasi is offline
 
Join Date: Mar 2008
Location: Tarragona
Posts: 31
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Ok, now I see the error

Please, test this code (this is going to fix the tintin74 problem too) and tell if it works to upgrade the "release"

The damn code BBCode don't seems to work...

<script type="text/javascript">
function checkURL()
{
if ((url.indexOf("http://")!=url.lastIndexOf("http://"))||url.lastIndexOf("http://")!=0){return false;}
if (url.indexOf('"')>=0) {return false;}
if (url.indexOf("http://maps.google")!=0){return false;}
return true
}

tot='';
tot_ini="{param}";
tot_no_quo=tot_ini.replace(/&quot;/g,'"');
if(tot_no_quo.indexOf("[url=")>0)
{ tot=tot_no_quo.substr(tot_no_quo.indexOf('[url="')+6,tot_no_quo.length);}
else
{ tot=tot_no_quo.substr(tot_no_quo.indexOf('src="')+ 5,tot_no_quo.length);}
url=tot.substr(0,tot.indexOf('"'));
urlp=url.replace(/amp;/g,'');
url=urlp;

if (checkURL())
{
document.write('<iframe width="640" height="480" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="'+url+'"></iframe>');
}
else
{
document.write("<p><b>Wrong map URL, edit the post to change it.</b></p>Reload the page when finished to check if correct.");
}
</script>
Reply With Quote
  #57  
Old 10-27-2008, 07:22 AM
tintin74 tintin74 is offline
 
Join Date: Jul 2007
Posts: 49
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Yeeeeessss! Thank you very much , Oasi!
Reply With Quote
  #58  
Old 10-27-2008, 08:37 AM
segwayon segwayon is offline
 
Join Date: Mar 2008
Posts: 152
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by oasi View Post
Ok, now I see the error

Please, test this code (this is going to fix the tintin74 problem too) and tell if it works to upgrade the "release"

The damn code BBCode don't seems to work...
I get the "Wrong map URL, edit the post to change it." message with the 1.0 script, and nothing gets rendered with this one.
Reply With Quote
  #59  
Old 10-27-2008, 08:50 AM
oasi oasi is offline
 
Join Date: Mar 2008
Location: Tarragona
Posts: 31
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Please, could you paste the generated code for your page, as LeoBrazil did, or paste an example URL?

If I can see the value for the tot_ini variable I would be able to figure what's wrong...
Reply With Quote
  #60  
Old 10-27-2008, 10:26 AM
Leo Brazil's Avatar
Leo Brazil Leo Brazil is offline
 
Join Date: Dec 2007
Location: Brazil
Posts: 485
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

With the new code I've got double error messages.

Here is what I've got from the source code. I'm still using the same link from Google maps for tests.

[CODE] <!-- message -->
<div id="post_message_27"><font face="Arial"><script type="text/javascript">
function checkURL()
{
if ((url.indexOf("http://")!=url.lastIndexOf("http://"))||url.lastIndexOf("http://")!=0){return false;}
if (url.indexOf('"')>=0) {return false;}
if (url.indexOf("http://maps.google")!=0){return false;}
return true
}

tot='';
tot_ini="&lt;iframe width=&quot;425&quot; height=&quot;350&quot; frameborder=&quot;0&quot; scrolling=&quot;no&quot; marginheight=&quot;0&quot; marginwidth=&quot;0&quot; src=&quot;";
tot_no_quo=tot_ini.replace(/&quot;/g,'"');
if(tot_no_quo.indexOf("http://maps.google.com/maps?f=q&amp;amp;hl=pt-BR&amp;amp;q=Liberdade,+S%C3%A3o+Paulo+-+SP,+Brasil&amp;amp;ie=UTF8&amp;amp;cd=1&amp;amp;g eocode=FdJhmP4de304_Q&amp;amp; ll=-23.558323,-46.62529&amp;amp;spn=0.036583,0.054932&amp;amp;z=1 4&amp;amp;iwloc=addr&amp;amp;o utput=embed&amp;amp;s=AARTsJrSb_gFa1Ssu_1wwOFTDbl5 gJKezg&quot;&gt;&lt;/iframe&gt;&lt;br /&gt;&lt;small&gt;&lt;a href=&quot;http://maps.google.com/maps?f=q&amp;amp;hl=pt-BR&amp;amp;q=Liberdade,+S%C3%A3o+Paulo+-+SP,+Brasil&amp;amp;ie=UTF8&amp;amp;cd=1&amp;amp;g eocode=FdJhmP4de304_Q&amp;amp; ll=-23.558323,-46.62529&amp;amp;spn=0.036583,0.054932&amp;amp;z=1 4&amp;amp;iwloc=addr&amp;amp;s ource=embed&quot; style=&quot;color:#0000FF;text-align:left&quot;&gt;Exibir mapa ampliado&lt;/a&gt;&lt;/small&gt;";
tot_no_quo=tot_ini.replace(/&quot;/g,'"');
if(tot_no_quo.indexOf("[url=")>0)
{ tot=tot_no_quo.substr(tot_no_quo.indexOf('[url="')+6,tot_no_quo.length);}
else
{ tot=tot_no_quo.substr(tot_no_quo.indexOf('src="')+ 5,tot_no_quo.length);}
url=tot.substr(0,tot.indexOf('"'));
urlp=url.replace(/amp;/g,'');
url=urlp;

if (checkURL())
{
document.write('<iframe width="640" height="480" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="'+url+'"></iframe>');
}
else
{
document.write("<p><b>Endereço errado do Mapa, edite seu post para alterá-lo.</b></p>Recarregue a página quando verificar que está correto.");
}
</script></div>
<!-- / message -->[/CODE]
Reply With Quote
  #61  
Old 10-27-2008, 10:54 AM
oasi oasi is offline
 
Join Date: Mar 2008
Location: Tarragona
Posts: 31
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Leo

You have to set the option "Disable BB Code Within This BB Code" to yes when you add the gmap code...

I think the problem is that gmap takes as parameter {param} all the content you put between [gmap] and [/gmap], but if the url BBcode is also between [gmap] and [/gmap] other different {param} value is appeared and the gmap addon can't catch the value for the iframe, and the content appears 2 times, but without a valid value.

There is no workaround with this I fear ...

Despite of this, in my forums I use the WYSIWYG editor and I'm not having all these weird problems, I don't figure how this is happening if you verified those values

Use {option}: -> No
Remove Tag If Empty -> Yes
Disable BB Code Within This BB Code -> Yes
Disable Smilies Within This BB Code -> Yes
Disable Word Wrapping Within This BB Code ->Yes
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 04:49 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04956 seconds
  • Memory Usage 2,334KB
  • Queries Executed 25 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (4)bbcode_code
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_post
  • (1)navbar
  • (6)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (4)pagenav_pagelink
  • (11)post_thanks_box
  • (11)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (11)post_thanks_postbit_info
  • (10)postbit
  • (11)postbit_onlinestatus
  • (11)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete