Skip to content

Instantly share code, notes, and snippets.

@Gix075 Gix075/easyGMap-0.6.0.js
Last active Aug 29, 2015

Embed
What would you like to do?
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
You can’t perform that action at this time.