Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,7 @@ This is my place
* `draggable` - if false, prevents the map from being dragged | default true
* `panControl` - the enabled/disabled state of the pan control. | default true
* `iconurl` - absolute path to a custom marker icon
* `ptlat` - marker latitude **(optiona)**
* `ptlng` - marker longitude **(optiona)**

the optional wrapped content is the **infowindow** content
13 changes: 12 additions & 1 deletion js/google-maps.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,17 @@ jQuery(document).ready(function () {
$mapDivs.each(function (index) {
var lat = parseFloat($(this).data('lat'));
var lng = parseFloat($(this).data('lng'));
var ptlat = $(this).data('ptlat');
var ptlng = $(this).data('ptlng');

if(ptlat != undefined && ptlng != undefined) {
ptlat = parseFloat(ptlat);
ptlng = parseFloat(ptlng);
} else {
ptlat = lat;
ptlng = lng;
}

var zoom = parseInt($(this).data('zoom'));
var scrollwheel = Boolean($(this).data('scrollwheel'));
var draggable = Boolean($(this).data('draggable'));
Expand All @@ -19,7 +30,7 @@ jQuery(document).ready(function () {
});

var marker = new google.maps.Marker({
position: {lat: lat, lng: lng},
position: {lat: ptlat, lng: ptlng},
icon: icon,
map: map,
animation: google.maps.Animation.DROP,
Expand Down
2 changes: 2 additions & 0 deletions shortcodes/MapShortcode.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ public function init()
'width' => $sc->getParameter('width', '600px'),
'height' => $sc->getParameter('height', '400px'),
'lat' => $sc->getParameter('lat', 44.540),
'ptlat' => $sc->getParameter('ptlat', null),
'lng' => $sc->getParameter('lng', -78.546),
'ptlng' => $sc->getParameter('ptlng', null),
'zoom' => $sc->getParameter('zoom', 8),
'scrollwheel' => $sc->getParameter('scrollwheel', true),
'draggable' => $sc->getParameter('draggable', true),
Expand Down
6 changes: 6 additions & 0 deletions templates/partials/google-maps.html.twig
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
<div id="map-{{ hash }}" class="google-map" style="width: {{ width }}; height: {{ height }}"
data-lat="{{ lat }}"
data-lng="{{ lng }}"
{% if ptlat != null %}
data-ptlat="{{ ptlat }}"
{% endif %}
{% if ptlng != null %}
data-ptlng="{{ ptlng }}"
{% endif %}
data-zoom="{{ zoom }}"
data-scrollwheel="{{ scrollwheel }}"
data-draggable="{{ draggable }}"
Expand Down