Skip to content

Commit

Permalink
added license file, apikey to match google maps requirements
Browse files Browse the repository at this point in the history
  • Loading branch information
JLNNN committed May 13, 2016
1 parent e5f4876 commit 5403eda
Showing 1 changed file with 27 additions and 17 deletions.
44 changes: 27 additions & 17 deletions js/main.js
Original file line number Diff line number Diff line change
@@ -1,31 +1,39 @@
var gmapswidget = {
defaultZoom : 13,

loadGMaps : function() {
/**
* An easy to use Google-Maps widget
*
* @author Julian Stock <[email protected]>
* @version 1.0.0
* @license MIT
*/

var gmapswidget = {
defaultZoom: 13,

loadGMaps: function(apiKey) {
if ($("div.gmap").length > 0) {
$.getScript("http://maps.google.com/maps/api/js?sensor=true&callback=gmapswidget._showGMaps", function(data, textStatus, jqxhr) {
$.getScript("http://maps.google.com/maps/api/js?key=" + apiKey + "&sensor=true&callback=gmapswidget._showGMaps", function(data, textStatus, jqxhr) {
// loaded
});
}
},

_showGMaps : function() {
_showGMaps: function() {
function initMap(x, y, i, z) {
var map, style = [];
var center = new google.maps.LatLng(x, y);
var settings = {
mapTypeId : google.maps.MapTypeId.ROADMAP,
zoom : z,
center : center,
styles : style,
scrollwheel : false
mapTypeId: google.maps.MapTypeId.ROADMAP,
zoom: z,
center: center,
styles: style,
scrollwheel: false
};

map = new google.maps.Map(document.getElementsByClassName('gmap')[i], settings);

function attachSecretMessage(marker, message) {
var infowindow = new google.maps.InfoWindow({
content : message
content: message
});
google.maps.event.addListener(marker, 'click', function() {
infowindow.open(map, marker);
Expand All @@ -37,10 +45,10 @@ var gmapswidget = {
var yP = $(el).data("gmarker-coords").split(",")[1];

var marker = new google.maps.Marker({
position : new google.maps.LatLng(xP, yP),
title : $(el).data("gmarker-title"),
animation : google.maps.Animation.DROP,
map : map
position: new google.maps.LatLng(xP, yP),
title: $(el).data("gmarker-title"),
animation: google.maps.Animation.DROP,
map: map
});

marker.setTitle(marker.title.toString());
Expand Down Expand Up @@ -83,5 +91,7 @@ var gmapswidget = {
};

$(function() {
gmapswidget.loadGMaps();
// https://console.developers.google.com/
let apiKey = "INSERT YOUR API KEY HERE";
gmapswidget.loadGMaps(apiKey);
});

0 comments on commit 5403eda

Please sign in to comment.