Skip to content

adding L.icon (raster icon) #36

Open

Description

@rghosh0

I tried a small, naive change to add raster icons (using the L.icon class), but I see this weird effect where raster icons sometimes appear, and sometimes don't:

http://ec2-54-198-8-124.compute-1.amazonaws.com/testpage/

Zooming in and out results in different raster icon instances showing up each time. If I have both icons and normal point styling, then the point styling always shows up, in contrast to the icons.

I was wondering if anyone had any ideas, or suggestions for an approach to debug this?

The diff is simply this:

--- a/src/StaticLabel/StaticLabel.js
+++ b/src/StaticLabel/StaticLabel.js
@@ -26,11 +26,22 @@ function StaticLabel(mvtFeature, ctx, latLng, style) {
 function init(self, mvtFeature, ctx, latLng, style) {
   var ajaxData = mvtFeature.ajaxData;
   var sty = self.style = style.staticLabel(mvtFeature, ajaxData);
-  var icon = self.icon = L.divIcon({
-    className: sty.cssClass || 'label-icon-text',
-    html: sty.html,
-    iconSize: sty.iconSize || [50,50]
-  });
+
+  var icon;
+  if (sty.iconUrl) {
+    icon = self.icon = L.icon({
+      className: sty.cssClass || 'label-icon-text',
+      html: sty.html,
+      iconUrl: sty.iconUrl,
+      iconSize: sty.iconSize || [50,50]
+    });
+  } else {
+    icon = self.icon = L.divIcon({
+      className: sty.cssClass || 'label-icon-text',
+      html: sty.html,
+      iconSize: sty.iconSize || [50,50]
+    });
+  }

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions