-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathjquery.googleMap.min.js
9 lines (8 loc) · 1.49 KB
/
jquery.googleMap.min.js
1
2
3
4
5
6
7
8
9
/**
* jQuery Google Map Helper
* Copyright (c) 2011 Kevin Doyle
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
**/
(function(f){f.fn.googleMap=function(a){a=f.extend({address:!1,LatLng:[[0,0]],content:!1,zoom:8,icon:!1,alt:!1,mapType:"roadmap",onGeocodeError:function(){}},a);return this.each(function(){var c=f(this)[0],d=new google.maps.LatLng(a.LatLng[0][0],a.LatLng[0][1]),b,e;switch(a.mapType){case "roadmap":b=google.maps.MapTypeId.ROADMAP;break;case "satellite":b=google.maps.MapTypeId.SATELLITE;break;case "hybrid":b=google.maps.MapTypeId.HYBRID;break;case "terrain":b=google.maps.MapTypeId.TERRAIN}b={zoom:"auto"=== a.zoom?0:a.zoom,center:d,mapTypeId:b};d=new google.maps.LatLngBounds;e=new google.maps.Map(c,b);if(a.address)d=new google.maps.Geocoder,d.geocode({address:a.address},function(b,c){if(c===google.maps.GeocoderStatus.OK){e.setCenter(b[0].geometry.location);var d=new google.maps.Marker({map:e,position:b[0].geometry.location,icon:a.icon?a.icon:null});if(!1!=a.content){var f=new google.maps.InfoWindow({content:a.content});google.maps.event.addListener(d,"click",function(){f.open(e,d)})}}else c===google.maps.GeocoderStatus.ZERO_RESULTS&& a.onGeocodeError.call(this)});else{for(c=0;c<=a.LatLng.length-1;c++)b=new google.maps.LatLng(a.LatLng[c][0],a.LatLng[c][1]),b=new google.maps.Marker({map:e,position:b,icon:a.icon?a.icon:null}),d.extend(b.getPosition());"auto"===a.zoom&&e.fitBounds(d)}})}})(jQuery);