Difference between #3 and #4 of
Using Google Maps in Yii Applications via Jquery

Revision #4 has been created by bluyell on Apr 10, 2013, 5:45:35 PM with the memo:

multiple selectors allowed
« previous (#3)

Changes

Title unchanged

Using Google Maps in Yii Applications via Jquery

Category unchanged

How-tos

Yii version unchanged

Tags unchanged

jquery, google, googlemap, maps, ui

Content changed

[...]
~~~
[javascript]
<script>
$.fn.googlemap = function(){
        var z = $(this);
 
        
// author: Christian Salazar, <christiansalazarh@gmail.com>          var src='';
 
$(this).each(function(){
 
var z = $(this);
 
var address = jQuery.trim(z.attr('streetnumber'))                  +'+'+jQuery.trim(z.attr('streetname'))                  +'+'+jQuery.trim(z.attr('cityname'))                  +'+'+jQuery.trim(z.attr('statecode'))                  +'+'+jQuery.trim(z.attr('zipcode'))         ;
 
        var 
;
 
src="https://maps.google.com/maps?"                  +"client=safari"                 +"&q="+address
 
                
+"&q="+address
 
+"&oe=UTF-8&ie=UTF8&hq="                  +"&hnear="+address                 +"&gl=us"
 
                
+"&gl=us"
 
+"&z="+z.attr('zoom')                  +"&output=embed";          z.html("<iframe src='"+src+"' width="+z.attr('width')+" height="                  +z.attr('height')+"></iframe>");          });
 
return src;
}
</script>
[...]
[javascript]
<script>$('#map').googlemap();</script>
//
please dontyou can use it forin multiple selectors, // as an example: $("ul.maps li").googlemap();
 
// will process all LI items having the required attributes
 
// displaying a map each.
 
~~~

It will produce:

![](http://4.bp.blogspot.com/-NWEZJTERR5A/UWWWwWnRMWI/AAAAAAAAAUY/3WH8lwge9wA/s400/googlemap.jpg "a google map - address based")
[...]
2 0
6 followers
Viewed: 23 259 times
Version: 1.1
Category: How-tos
Written by: bluyell
Last updated by: bluyell
Created on: Apr 10, 2013
Last updated: 10 years ago
Update Article

Revisions

View all history