Last active
August 29, 2015 14:16
-
-
Save Gix075/1929dc70e2ddaf4cd792 to your computer and use it in GitHub Desktop.
Function for a GoogleMap in a div
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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