Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding L.icon (raster icon) #36

Open
rghosh0 opened this issue Aug 18, 2015 · 0 comments
Open

adding L.icon (raster icon) #36

rghosh0 opened this issue Aug 18, 2015 · 0 comments

Comments

@rghosh0
Copy link

rghosh0 commented Aug 18, 2015

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]
+    });
+  }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant