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")[...]