fix icon definition for cases where marker_icon is None in adapters

and add backward (pre-0.4.2) compat of marker.icon

closes #5739655

authorAdrien Di Mascio <Adrien.DiMascio@logilab.fr>
changeset1152a7ea023d
branchdefault
phasepublic
hiddenno
parent revision#77945db69179 Added tag cubicweb-leaflet-version-0.4.2, cubicweb-leaflet-debian-version-0.4.2-1, cubicweb-leaflet-centos-version-0.4.2-1 for changeset 0bbf2deadd3a
child revision#fd98699c674c preparing 0.4.3
files modified by this revision
data/cubes.leaflet.js
# HG changeset patch
# User Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
# Date 1437741886 -7200
# Fri Jul 24 14:44:46 2015 +0200
# Node ID 1152a7ea023df729bfd87b499cc3fdc1747c2972
# Parent 77945db69179f984ddcdc5531b660e65fc551094
fix icon definition for cases where marker_icon is None in adapters

and add backward (pre-0.4.2) compat of marker.icon

closes #5739655

diff --git a/data/cubes.leaflet.js b/data/cubes.leaflet.js
@@ -33,11 +33,14 @@
1                  var cluster = new L.MarkerClusterGroup();
2              }
3              var bounds = new L.LatLngBounds();
4              $.each(markers, function(_, marker) {
5                  var options = {};
6 -                if (marker.icon_options !== undefined) {
7 +                if (marker.icon) {
8 +                    cw.log('[leaflet-0.4.2] icon property is deprecated in marker definition, use icon_options instead');
9 +                    options.icon = L.icon({iconUrl: marker.icon});
10 +                } else if (marker.icon_options && marker.icon_options.iconUrl) {
11                      options.icon = L.icon(marker.icon_options);
12                  }
13                  var mapMarker = L.marker([marker.latitude, marker.longitude],
14                                           options, marker).bindPopup($.format(marker.popup, marker));
15                  if (!settings.initialZoom) {