adt-js-components 1.5.0 → 1.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/Map/index.js +11 -8
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "adt-js-components",
3
- "version": "1.5.0",
3
+ "version": "1.5.2",
4
4
  "description": "JavaScript components for Nette framework",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/src/Map/index.js CHANGED
@@ -6,10 +6,12 @@ import "leaflet.markercluster/dist/MarkerCluster.css";
6
6
  import "leaflet.markercluster/dist/MarkerCluster.Default.css";
7
7
 
8
8
  let siteKey;
9
+ let markerImg;
9
10
  const mapInstances = new WeakMap();
10
11
 
11
12
  async function run(options) {
12
13
  siteKey = options.siteKey;
14
+ markerImg = options.markerImg;
13
15
 
14
16
  function applyEventHandlers(el) {
15
17
  const { position, zoom, hideControl = false, markers = [], callback } = JSON.parse(el.dataset.adtMap);
@@ -54,20 +56,21 @@ async function run(options) {
54
56
  map.dragging.disable();
55
57
  }
56
58
 
57
- const markerOptions = {
58
- icon: L.icon({
59
- iconUrl: '//' + window.location.hostname + '/images/mapmarker.png',
60
- }),
61
- };
59
+ const markerOptions = {};
60
+ if (markerImg) {
61
+ markerOptions.icon = L.icon({
62
+ iconUrl: markerImg,
63
+ });
64
+ }
62
65
  if (markers.length) {
63
66
  const markerPositions = [];
64
67
  const cluster = L.markerClusterGroup({
65
68
  disableClusteringAtZoom: map.getMaxZoom()
66
69
  });
67
70
  for (const marker of markers) {
68
- const mapMarker = L.marker(marker.position, markerOptions);
69
- if (marker.handler) {
70
- mapMarker.on('click', marker.handler);
71
+ const mapMarker = L.marker(marker.position, {...markerOptions, id: marker.id});
72
+ if (marker.callback) {
73
+ mapMarker.on('click', window[marker.callback]);
71
74
  }
72
75
  if (marker.popup) {
73
76
  mapMarker.bindPopup(marker.popup)