Skip to content

Commit

Permalink
Fixed map
Browse files Browse the repository at this point in the history
  • Loading branch information
janhenckens committed Sep 28, 2024
1 parent fe0ecad commit 47565b5
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.MD
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Release Notes for Easy Address Field for Craft CMS

## 5.0.3 - 2024-09-28
### Fixed
- Fixed the map showing a blank screen when no coordinates could be found

## 5.0.2 - 2024-09-09
### Fixed
- Better error catching on Nomanatim errors ([#39](https://github.com/studioespresso/craft-easyaddressfield/issues/39))
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "studioespresso/craft-easyaddressfield",
"description": "The only address field you need",
"type": "craft-plugin",
"version": "5.0.2",
"version": "5.0.3",
"keywords": [
"cms",
"craftcms",
Expand Down
13 changes: 5 additions & 8 deletions src/assetbundles/easyaddressfield/dist/js/EasyAddressField.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,22 +36,21 @@

var lat = $('#' + handle + '-latitude').val();
var lng = $('#' + handle + '-longitude').val();
var link = $('#' + handle + '-drag-pin-data');
var defaultData = { 'lat': link.data('lat'), 'lng': link.data('lng')};

var defaultData = $('#' + handle + '-drag-pin-data').data();
console.log(defaultData);
if (lat && lng && !isNaN(lat) && !isNaN(lng)) {
coords = {
'lat': lat,
'lng': lng
};
} else if (defaultData.default) {
} else if (defaultData) {
coords = {
'lat': defaultData.lat,
'lng': defaultData.lng
};
zoom = defaultData.zoom;
}

zoom = defaultData.zoom;
var marker = renderMapOSM(handle, mapCanvas, coords, zoom);

$('.modal-cancel').on('click', function () {
Expand All @@ -66,15 +65,13 @@
$('#' + handle + '-longitude').val(marker.getLatLng().lng);
return false;
});

clearInterval(refreshIntervalId);
}

}, 10);
}

function renderMapOSM(handle, mapCanvas, coords, zoom) {
console.log(zoom);
function renderMapOSM(handle, mapCanvas, coords, zoom = 14) {
if(dragPin[handle]['map'] === false) {
dragPin[handle]['map'] = L.map(mapCanvas).setView([coords.lat,coords.lng], zoom);
}
Expand Down
2 changes: 1 addition & 1 deletion src/templates/_field/_input.twig
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@
<div style="color: #576575; cursor: pointer; display: inline-block;" class="inline">
<div class="easyaddressfield-marker inline">
<svg style="display: inline;" height="28" enable-background="new 0 0 26 26" id="Слой_1" version="1.1" viewBox="0 0 26 26" xml:space="preserve" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><g><path d="M24.9021606,21.0473633c0.0229492-0.0432129,0.0421753-0.0855103,0.0563354-0.1323242 c0.0135498-0.0444336,0.0206909-0.088562,0.0258179-0.1355591c0.0056152-0.0511475,0.0065308-0.1004639,0.0014038-0.1525879 c-0.0022583-0.0233154,0.005127-0.0452881,0.0006104-0.0687866l-1.8310547-9.4819336 c-0.0066528-0.0340576-0.0269165-0.0604248-0.0377197-0.0924072c-0.010498-0.0315552-0.0098267-0.0643921-0.0247803-0.0950928 c-0.0075684-0.0155029-0.0216675-0.0246582-0.0301514-0.0393677c-0.0272217-0.0478516-0.0612183-0.0872192-0.0975342-0.1273193 c-0.0292358-0.0321655-0.0559082-0.0645752-0.0897827-0.0908203c-0.0409546-0.0319824-0.0859985-0.053894-0.1328735-0.0767212 c-0.0407715-0.0198975-0.0791626-0.0401001-0.1227417-0.0523682c-0.0438843-0.0122681-0.0886841-0.0148926-0.1351318-0.0188599 c-0.053833-0.0049438-0.1057129-0.0080566-0.1601563-0.0009766c-0.0164185,0.0021362-0.0314941-0.003479-0.0480347-0.0003052 c-0.0328979,0.0063477-0.0581665,0.0263672-0.0891113,0.0366821c-0.0322876,0.0108032-0.06604,0.0101929-0.0974121,0.0258179 l-2.7524414,1.345459c0.4395142-0.8766479,0.7983398-1.9657593,0.7983398-3.2058105 c0-3.9213867-3.1787109-7.1137695-7.0927734-7.1342773c-0.0097656,0-0.0175781,0-0.0253906,0s-0.015625,0-0.0253906,0 c-3.9150391,0.0205078-7.09375,3.2128906-7.09375,7.1342773c0,1.2284546,0.3527222,2.30896,0.7872314,3.1819458 l-3.4337158,1.6784058c-0.0142822,0.007019-0.0227051,0.0200806-0.0363159,0.027832 c-0.0516968,0.0290527-0.0952148,0.0656128-0.1384888,0.1061401c-0.0292358,0.0274048-0.0584106,0.0525513-0.0826416,0.0838013 c-0.0309448,0.039978-0.0528564,0.0843506-0.0754395,0.1307983c-0.0216675,0.0441895-0.041748,0.0866699-0.0544434,0.1341553 c-0.0046387,0.0175171-0.0164185,0.0309448-0.0198975,0.0490112l-1.8310547,9.4819336 c-0.0045776,0.0238647,0.0028687,0.0462036,0.0006104,0.0699463c-0.005127,0.0510254-0.0041504,0.1002808,0.0014038,0.1520996 c0.0055542,0.0505371,0.0148315,0.0975952,0.0302124,0.1452026c0.0073853,0.0233154,0.0048218,0.0473022,0.0146484,0.0702515 c0.0126343,0.0294189,0.0331421,0.052002,0.0488892,0.0789185c0.013916,0.0238037,0.0262451,0.046875,0.0426636,0.0689697 c0.046814,0.0631714,0.100769,0.118042,0.1628418,0.1625366c0.0079956,0.0057983,0.0136108,0.0137329,0.0218506,0.019165 c0.0743408,0.0490723,0.1575317,0.0802612,0.2441406,0.1004028c0.0096436,0.0022583,0.0167236,0.0090332,0.0264893,0.0109253 c0.0478516,0.0090942,0.0947876,0.0133057,0.1407471,0.0134277c0.0006104,0,0.0012207,0.0002441,0.0018311,0.0002441 c0.0001221,0,0.0001831-0.000061,0.0003052-0.000061c0.0002441,0,0.0004272,0.000061,0.0006714,0.000061 c0.0962524,0,0.1879883-0.0219116,0.274353-0.0563354c0.0067749-0.0026245,0.013855-0.0013428,0.0205688-0.0042114 l6.730957-2.8847046L17,24.4072266c0.0056763,0.0020142,0.0113525,0.0010986,0.0170288,0.0029297 C17.09198,24.4347534,17.1699219,24.4501953,17.25,24.4501953c0.092041,0,0.1802979-0.0219116,0.2647095-0.0541382 c0.0102539-0.0038452,0.0209961-0.0020752,0.031189-0.0064087l7-3c0.022522-0.0096436,0.0369263-0.0285645,0.0579834-0.0401001 c0.0446777-0.0244141,0.0838623-0.052002,0.1220703-0.0843506c0.0371094-0.0313721,0.0704956-0.0629272,0.1004028-0.1002197 C24.8562012,21.1279297,24.8797607,21.0894165,24.9021606,21.0473633z M4.24646,14.7277222l3.2199707-1.5739136 l1.3627319,1.8533936l-0.5172119,5.0644531l-5.5574341,2.3817749L4.24646,14.7277222z M9.3131714,20.1036987l0.3980103-3.8969116 l2.689209,3.6574707c0.1416016,0.1923828,0.3916016,0.3056641,0.6298828,0.3056641s0.4628906-0.1137695,0.6044922-0.3056641 l2.3893433-3.2503662l0.6206055,6.0773926L9.3131714,20.1036987z M17.6513062,22.7119141l-0.7452393-7.2978516l0.7644653-1.039978 l4.1978149-2.052002l1.5307007,7.9265747L17.6513062,22.7119141z M13.0175781,3.0498047 c3.0996094,0.0068359,5.6181641,2.5317383,5.6181641,5.6342773c0,1.4643555-0.6523438,2.699707-1.2050781,3.484375 c-0.0019531,0.0024414-0.0039063,0.0043945-0.0058594,0.0068359l-4.4072266,5.9956055l-4.3916016-5.9731445 C8.6230469,12.1943359,8.6210938,12.190918,8.6181641,12.1875c-0.5566406-0.7841797-1.2197266-2.0283203-1.2197266-3.503418 C7.3984375,5.581543,9.9179688,3.0566406,13.0175781,3.0498047z" fill="#1D1D1B"/><path d="M13.0302734,11.847168c1.7412109,0,3.1582031-1.4189453,3.1582031-3.1630859 s-1.4169922-3.1630859-3.1582031-3.1630859c-1.7421875,0-3.1591797,1.4189453-3.1591797,3.1630859 S11.2880859,11.847168,13.0302734,11.847168z M13.0302734,6.5209961c1.1904297,0,2.1582031,0.9702148,2.1582031,2.1630859 s-0.9677734,2.1630859-2.1582031,2.1630859s-2.1591797-0.9702148-2.1591797-2.1630859S11.8398438,6.5209961,13.0302734,6.5209961z" fill="#1D1D1B"/></g></svg>
<a href="javascript:;" id="{{ name }}-drag-pin-data" style="color: #4168cf; font-weight: bold;" >
<a href="javascript:;" id="{{ name }}-drag-pin-data" style="color: #4168cf; font-weight: bold;" data-lat="0.0" data-lng="0.0">
{{ "Pick an address on the map"|t('easy-address-field') }}
</a>
</div>
Expand Down

0 comments on commit 47565b5

Please sign in to comment.