christiansalazarh

google map example

Apr 10th, 2013
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
jQuery 0.91 KB | None | 0 0
  1. <script>
  2. $.fn.googlemap = function(){
  3.     // author: Christian Salazar <christiansalazarh@gmail.com>
  4.     var src='';
  5.     $(this).each(function(){
  6.     var z = $(this);
  7.     var address = jQuery.trim(z.attr('streetnumber'))
  8.         +'+'+jQuery.trim(z.attr('streetname'))
  9.         +'+'+jQuery.trim(z.attr('cityname'))
  10.         +'+'+jQuery.trim(z.attr('statecode'))
  11.         +'+'+jQuery.trim(z.attr('zipcode'))
  12.     ;
  13.     src="https://maps.google.com/maps?"
  14.         +"client=safari"
  15.         +"&q="+address
  16.         +"&oe=UTF-8&ie=UTF8&hq="
  17.         +"&hnear="+address
  18.         +"&gl=us"
  19.         +"&z="+z.attr('zoom')
  20.         +"&output=embed";
  21.         z.html("<iframe src='"+src+"' width="+z.attr('width')+" height="
  22.         +z.attr('height')+"></iframe>");
  23.     });
  24.     return src;
  25. }
  26. </script>
  27. <?php
  28. /*
  29. <div id='mapa' streetnumber='946' streetname='LAKE+DESTINY+RD'
  30.     cityname='ALTAMONTE+SPRINGS' statecode='FL' zipcode='32714'
  31.     zoom=18 width=500 height=300>
  32. </div>
  33. <script>$('#mapa').googlemap();</script>
  34. */?>
Add Comment
Please, Sign In to add comment