var GoogleMap = (function($){ return{ //accept list of json markers as parameter to mark on the google map loadWithMarkers: function(listOfMarker){ if(listOfMarker!==null && listOfMarker.length> 0) { // map options var options = { zoom: 8, center: new google.maps.LatLng(listOfMarker[0].latitute, listOfMarker[0].longitute) }; var map = new google.maps.Map(document.getElementById('map_canvas'), options); $.each( listOfMarker, function(i, m) { var marker = new MarkerWithLabel({ position: new google.maps.LatLng(m.latitute, m.longitute), map: map, labelContent: m.number_of_open, labelClass: "labels", labelAnchor: new google.maps.Point(13, 65), icon: pinSymbol('red') }); // process multiple info windows (function(marker, i) { // add click event google.maps.event.addListener(marker, 'click', function() { infowindow = new google.maps.InfoWindow({ content: i18n.t("mydocument.dashboard.map.number_time_open") + m.number_of_open }); infowindow.open(map, marker); }); })(marker, i); // Draw Icon marker function pinSymbol(color) { return { path: 'M 0,0 C -2,-20 -10,-22 -10,-30 A 10,10 0 1,1 10,-30 C 10,-22 2,-20 0,0 z', fillColor: color, fillOpacity: 1, strokeColor: '#000', strokeWeight: 2, scale: 2 }; } }); } }, // Load last opened location of package detail loadLastLocation : function( location ){ if( location !== null && location !== undefined ){ // map options var options = { zoom: 10, center: new google.maps.LatLng(location.latitute, location.longitute) }; // init map var map = new google.maps.Map(document.getElementById('map_canvas'), options); var marker = new google.maps.Marker({ position: new google.maps.LatLng(location.latitute, location.longitute), map: map //label: location.last_open_date }); // add click event google.maps.event.addListener(marker, 'click', function() { infowindow = new google.maps.InfoWindow({ content: i18n.t("mydocument.dashboard.modal.last_open") + location.last_open_date }); infowindow.open(map, marker); }); } } }; }(jQuery));