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
  #62  
Old 10-28-2008, 12:21 PM
Leo Brazil's Avatar
Leo Brazil Leo Brazil is offline
 
Join Date: Dec 2007
Location: Brazil
Posts: 485
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by oasi View Post
Leo

You have to set the option "Disable BB Code Within This BB Code" to yes when you add the gmap code...
100% sure this is correct and I'm using this in my test forum without plugins installed.


Quote:
Originally Posted by oasi View Post
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.
If try to post the Google link directly it gaves me an error, if I edit the post I can see what happens with the link. All tags were included in it as below. I wrapped with HTML tags otherwise the editor would parse the link and you woundn't get what really happens. Check the tags that appears on the Google Link.

HTML Code:
[gmap]<iframe width="425" height="350" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="[/gmap][gmap][url="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=FdJhmP4de304_Q&amp;ll=-23.558323,-46.62529&amp;spn=0.036583,0.054932&amp;z=14&amp;iwloc=addr&amp;output=embed&amp;s=AARTsJrSb_gFa1Ssu_1wwOFTDbl5gJKezg"></iframe><br"][font=Arial][color=#0000ff]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=FdJhmP4de304_Q&amp;ll=-23.558323,-46.62529&amp;spn=0.036583,0.054932&amp;z=14&amp;iwloc=addr&amp;output=embed&amp;s=AARTsJrSb_gFa1Ssu_1wwOFTDbl5gJKezg"></iframe><br[/color][/font][/url][font=Arial] /><small><a href="[/font][url="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=FdJhmP4de304_Q&amp;ll=-23.558323,-46.62529&amp;spn=0.036583,0.054932&amp;z=14&amp;iwloc=addr&amp;source=embed"][font=Arial][color=#0000ff]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=FdJhmP4de304_Q&amp;ll=-23.558323,-46.62529&amp;spn=0.036583,0.054932&amp;z=14&amp;iwloc=addr&amp;source=embed[/color][/font][/url][font=Arial]" style="color:#0000FF;text-align:left">Exibir mapa ampliado</a></small>[/font][/gmap]

Quote:
Originally Posted by oasi View Post
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
That's exactly what I have here since the beginning.

I tought with Disable BB Code Within This BB Code -> Yes - I would never had what I'm getting on the example I gave above. You can still see com BB Codes on it. Weird huh ?
Reply With Quote
  #63  
Old 10-28-2008, 01:00 PM
oasi oasi is offline
 
Join Date: Mar 2008
Location: Tarragona
Posts: 31
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

And these BBcode tags are added automatically??

HTML Code:
src="[/gmap][gmap]
Tomorrow I'll try to solve it. The solution is going to add extra+unuseful code to the html, but I think it can work...
Reply With Quote
  #64  
Old 10-28-2008, 02:25 PM
Leo Brazil's Avatar
Leo Brazil Leo Brazil is offline
 
Join Date: Dec 2007
Location: Brazil
Posts: 485
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Yes, did you notice those in the middle, right ?

They were placed there buy the editor automaticaly, just after I clicked preveiw post.

Weird ? Yes, but I found why. The link I'm using as an example I placed on Microsoft Word File because I use to keep a file on WORD of all mods I like and use just to make my life easier to organize and for upgrades, check diferences. Same as I did with yours, visually nothing chances but I think WORD uses weird HTML or something the scroll this up. I did that as I was using exactly the same link for several tests it's faster than going to Google and check for the same link all the time, you know.

But now I just copy/paste directly from Google and this was what I've got:

HTML Code:
[gmap]<iframe width="425" height="350" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="[url]http://maps.google.com/maps?f=q&amp;hl=pt-BR&amp;q=Liberdade,+S%C3%A3o+Paulo+-+SP,+Brasil&amp;sll=37.0625,-95.677068&amp;sspn=32.38984,56.25&amp;ie=UTF8&amp;cd=1&amp;geocode=FdJhmP4de304_Q&amp;ll=-23.558323,-46.62529&amp;spn=0.036583,0.054932&amp;z=14&amp;g=Liberdade,+S%C3%A3o+Paulo+-+SP,+Brasil&amp;iwloc=addr&amp;output=embed&amp;s=AARTsJpM49-sTq_lIb07cjYCRnPUSvYXwA"></iframe><br[/url] /><small><a href="[url]http://maps.google.com/maps?f=q&amp;hl=pt-BR&amp;q=Liberdade,+S%C3%A3o+Paulo+-+SP,+Brasil&amp;sll=37.0625,-95.677068&amp;sspn=32.38984,56.25&amp;ie=UTF8&amp;cd=1&amp;geocode=FdJhmP4de304_Q&amp;ll=-23.558323,-46.62529&amp;spn=0.036583,0.054932&amp;z=14&amp;g=Liberdade,+S%C3%A3o+Paulo+-+SP,+Brasil&amp;iwloc=addr&amp;source=embed[/url]" style="color:#0000FF;text-align:left">Exibir mapa ampliado</a></small>[/gmap]
You'll see those between the link were gone but a lot of tags still remains the same and conparing the raw link with the this one those tags are causing this errors.

Sorry bugging you around with all those long posts I'm just trying to be usefull.
Reply With Quote
  #65  
Old 10-29-2008, 07:18 AM
oasi oasi is offline
 
Join Date: Mar 2008
Location: Tarragona
Posts: 31
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Ok,

I think this has to work...

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_quo=tot_ini.replace(/&quot;/g,'"');
if(tot_no_quo.indexOf("[url")>0)
{ //The URL affaire...
  if(tot_no_quo.indexOf('[url="')>0) {tot=tot_no_quo.substr(tot_no_quo.indexOf('[url="')+6,tot_no_quo.length);tot_no_quo='';}
  if(tot_no_quo.indexOf('[url=')>0)  {tot=tot_no_quo.substr(tot_no_quo.indexOf('[url=')+5,tot_no_quo.length);tot_no_quo='';a=tot.replace(/\]/g,'"');tot=a;}
  if(tot_no_quo.indexOf('[url]')>0)  {tot=tot_no_quo.substr(tot_no_quo.indexOf('[url]')+5,tot_no_quo.length);a=tot.replace(/\[/g,'"');tot=a;}
}
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>La URL que has passat per al mapa contenia errors, edita el post per arreglar-ho</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>
Reply With Quote
  #66  
Old 10-29-2008, 07:58 AM
cvn cvn is offline
 
Join Date: May 2006
Posts: 31
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Now I don't see the "wrong URL" error but see nothing displays. Nothing, no map nor error message.
Reply With Quote
  #67  
Old 10-29-2008, 10:03 AM
oasi oasi is offline
 
Join Date: Mar 2008
Location: Tarragona
Posts: 31
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Please, paste your tot_ini value here (view source for the page)...
Reply With Quote
  #68  
Old 10-29-2008, 02:06 PM
cvn cvn is offline
 
Join Date: May 2006
Posts: 31
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Certainly!

Here is the code I used with [GMAP] tag:
PHP Code:
<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=FdJhmP4de304_Q&amp;ll=-23.558323,-46.62529&amp;spn=0.036583,0.054932&amp;z=14&amp;iwloc=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=FdJhmP4de304_Q&amp;ll=-23.558323,-46.62529&amp;spn=0.036583,0.054932&amp;z=14&amp;iwloc=addr&amp;source=embed" style="color:#0000FF;text-align:left">Exibir mapa ampliado</a></small
And here the source code of my page after posted:

PHP 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="<iframe width="425" height="350" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.com/?ie=UTF8&amp;ll=40.84706,-98.448486&amp;spn=2.576261,5.806274&amp;z=8&amp;output=embed&amp;s=AARTsJqzARj-Z8VnW5pkPMLMmZbqrJcYpw"></iframe><br /><small><a href="http://maps.google.com/?ie=UTF8&amp;ll=40.84706,-98.448486&amp;spn=2.576261,5.806274&amp;z=8&amp;source=embed" style="color:#0000FF;text-align:left">View Larger Map</a></small>";
tot_no_quo=tot_ini.replace(/&quot;/g,'"');
if(
tot_no_quo.indexOf("[url")>0)
//The URL affaire...
  
if(tot_no_quo.indexOf('[url="')>0) {tot=tot_no_quo.substr(tot_no_quo.indexOf('[url="')+6,tot_no_quo.length);tot_no_quo='';}
  if(
tot_no_quo.indexOf('[url=')>0)  {tot=tot_no_quo.substr(tot_no_quo.indexOf('[url=')+5,tot_no_quo.length);tot_no_quo='';a=tot.replace(/\]/g,'"');tot=a;}
  if(
tot_no_quo.indexOf('[url]')>0)  {tot=tot_no_quo.substr(tot_no_quo.indexOf('[url]')+5,tot_no_quo.length);a=tot.replace(/\[/g,'"');tot=a;}
}
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>La URL que has passat per al mapa contenia errors, edita el post per arreglar-ho</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
Reply With Quote
  #69  
Old 10-29-2008, 05:00 PM
FReeSTER FReeSTER is offline
 
Join Date: Jun 2006
Location: Rome
Posts: 730
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thank you for this BB code. Works great
Reply With Quote
  #70  
Old 10-29-2008, 07:23 PM
dreamer81 dreamer81 is offline
 
Join Date: Jul 2005
Posts: 62
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

how do I use this? is there installation instructions somewhere?
Reply With Quote
  #71  
Old 10-29-2008, 07:27 PM
Leo Brazil's Avatar
Leo Brazil Leo Brazil is offline
 
Join Date: Dec 2007
Location: Brazil
Posts: 485
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by oasi View Post
Ok,

I think this has to work...
Sorry but don't. I'm still getting the wrong URL and also all my previous posts that were working got the same wrong messages.

But worry, I wrote a very detailed instructions to my members and the first code published here is working fine with them. Just a pain to switch editor mode to do it but it's fine.

Tks.
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 03:40 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.02844 seconds
  • Memory Usage 2,361KB
  • Queries Executed 27 (?)
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
  • (2)bbcode_code
  • (3)bbcode_html
  • (2)bbcode_php
  • (4)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_postinfo_query
  • fetch_postinfo
  • 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