Skip to content

Instantly share code, notes, and snippets.

@Gix075
Last active August 29, 2015 14:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Gix075/1929dc70e2ddaf4cd792 to your computer and use it in GitHub Desktop.
Save Gix075/1929dc70e2ddaf4cd792 to your computer and use it in GitHub Desktop.
Function for a GoogleMap in a div
/* easyGMap 0.6.0
* --------------------------------------------
* GoogleMap API and jQuery nedeed!
* This is the latest version of this tool.
* See documentation at http://factory.brainleaf.eu/tools/jquery/easy-gmap
*/
function easyGMap() {
this.getMap = function(opts) {
this.infoBoxMarkup = '<div class="easygmap_mapinfobox">'+
' <div class="easygmap_mapinfobox-sitenotice">'+
''+
' </div>'+
' <h3 class="easygmap_mapinfobox-heading">'+ opts.infoBoxTitle +'</h3>'+
' <div class="easygmap_mapinfobox-content">'+
' <p>' + opts.infoBoxDescription + '</p>'+
' </div>'+
'</div>';
mapFromCoords(this.infoBoxMarkup,opts);
}
function mapFromCoords(infoBoxMarkup,opts) {
var map_canvas = document.getElementById(opts.elementId);
var placePosition = new google.maps.LatLng(opts.mapLat,opts.mapLong);
var mapOptions = {
center: placePosition,
zoom: opts.mapZoom,
scrollwheel: false,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
// Map
var map = new google.maps.Map(map_canvas, mapOptions);
// InfoBox
var infowindow = new google.maps.InfoWindow({
content: infoBoxMarkup
});
// Marker
var marker = new google.maps.Marker({
position: placePosition,
map: map,
icon: opts.markerIcon,
title: opts.markerTitle
});
google.maps.event.addListener(marker, 'click', function() {
infowindow.open(map,marker);
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment