Skip to content

Commit 35e292c

Browse files
committed
implemented google maps asyncronous loading
1 parent 15a4837 commit 35e292c

File tree

4 files changed

+15
-9
lines changed

4 files changed

+15
-9
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
# v1.0.2
2+
## 27/05/2016
3+
4+
1. [](#improved)
5+
* implemented Google Maps asynchronous loading
6+
17
# v0.1.0
28
## 05/09/2016
39

blueprints.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: Google Maps
2-
version: 1.0.0
2+
version: 1.0.2
33
description: Google Maps plugin for Grav
4-
icon: code
4+
icon: map-marker
55
author:
66
name: Salvatore Guarino
77
email: sg@deved.it

js/google-maps.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
jQuery(document).ready(function () {
1+
function initMap () {
22
var $mapDivs = $('.google-map');
33
$mapDivs.each(function(index){
4-
var lat = $(this).data('lat');
5-
var lng = $(this).data('lng');
4+
var lat = parseFloat($(this).data('lat'));
5+
var lng = parseFloat($(this).data('lng'));
66
var zoom = $(this).data('zoom');
77
var window = $(this).data('infowindow');
88
var map = new google.maps.Map(this, {
@@ -29,4 +29,4 @@ jQuery(document).ready(function () {
2929
infowindow.open(map, marker);
3030
}
3131
});
32-
});
32+
}

shortcodes/MapShortcode.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ public function init()
1111
{
1212
$apikey = $this->grav['config']->get('plugins.google-maps.google_api_key');
1313
$apikeystring = ($apikey) ? "?key=$apikey" : "";
14+
1415
$this->shortcode->getHandlers()->add('google-maps', function(ShortcodeInterface $sc) use ($apikeystring) {
15-
1616
//add assets
17-
$this->shortcode->addAssets('js', 'https://maps.googleapis.com/maps/api/js'.$apikeystring);
18-
$this->shortcode->addAssets('js', 'plugin://google-maps/js/google-maps.js');
17+
$this->shortcode->addAssets('asyncJs', 'plugin://google-maps/js/google-maps.js');
18+
$this->shortcode->addAssets('asyncJs', 'https://maps.googleapis.com/maps/api/js'.$apikeystring.'&callback=initMap');
1919
$hash = $this->shortcode->getId($sc);
2020
$infowindow = $sc->getContent();
2121

0 commit comments

Comments
 (0)