1(function($){ 2 $.fn.mapmarker = function(options){ 3 var opts = $.extend({}, $.fn.mapmarker.defaults, options); 4 5 return this.each(function() { 6 // Apply plugin functionality to each element 7 var map_element = this; 8 addMapMarker( map_element, opts.zoom, opts.styles, opts.center, opts.markers ); 9 }); 10 }; 11 12 // Set up default values 13 var defaultMarkers = { 14 "markers": [] 15 }; 16 17 $.fn.mapmarker.defaults = { 18 zoom : 8, 19 center : 'Bangladesh', 20 markers : defaultMarkers 21 } 22 23 // Main function code here (ref:google map api v3) 24 function addMapMarker( map_element, zoom, styles, center, markers ){ 25 //console.log($.fn.mapmarker.defaults['center']); 26 27 //Set center of the Map 28 var myOptions = { 29 zoom: zoom, 30 styles: styles, 31 mapTypeId: google.maps.MapTypeId.ROADMAP, 32 } 33 var map = new google.maps.Map(map_element, myOptions); 34 var geocoder = new google.maps.Geocoder(); 35 var infowindow = null; 36 var baloon_text = ""; 37 38 geocoder.geocode( { 'address': center}, function(results, status) { 39 if (status == google.maps.GeocoderStatus.OK) { 40 //In this case it creates a marker, but you can get the lat and lng from the location.LatLng 41 map.setCenter(results[0].geometry.location); 42 } 43 else{ 44 console.log("Geocode was not successful for the following reason: " + status); 45 } 46 }); 47 48 //run the marker JSON loop here 49 $.each( markers.markers, function(i, the_marker){ 50 latitude = the_marker.latitude; 51 longitude = the_marker.longitude; 52 icon = the_marker.icon; 53 var baloon_text = the_marker.baloon_text; 54 55 if(latitude!="" && longitude!=""){ 56 var marker = new google.maps.Marker({ 57 map: map, 58 position: new google.maps.LatLng(latitude,longitude), 59 animation: google.maps.Animation.DROP, 60 icon: icon 61 }); 62 63 // Set up markers with info windows 64 google.maps.event.addListener(marker, 'click', function() { 65 // Close all open infowindows 66 if (infowindow) { 67 infowindow.close(); 68 } 69 70 infowindow = new google.maps.InfoWindow({ 71 content: baloon_text 72 }); 73 74 infowindow.open(map,marker); 75 }); 76 } 77 }); 78 } 79 80})(jQuery);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.