Fix some Leaflet asset loading issues
authorTom Hughes <tom@compton.nu>
Sun, 22 Sep 2013 10:47:45 +0000 (11:47 +0100)
committerTom Hughes <tom@compton.nu>
Sun, 22 Sep 2013 10:47:45 +0000 (11:47 +0100)
app/assets/javascripts/leaflet.extend.js.erb

index 6b7fac654b5b0ccb54e1f3bc7b45a43d395fe36b..966d0276b33c6827553dbcaaa9b1366bf4a77584 100644 (file)
@@ -155,7 +155,23 @@ L.extend(L.Map.prototype, {
   }
 });
 
-L.Icon.Default.imagePath = <%= "#{assets_prefix}/images".to_json %>;
+L.Icon.Default.imagePath = "/images";
+
+L.Icon.Default.imageUrls = {
+  "/images/marker-icon.png": "<%= asset_path("images/marker-icon.png") %>",
+  "/images/marker-icon-2x.png": "<%= asset_path("images/marker-icon-2x.png") %>",
+  "/images/marker-shadow.png": "<%= asset_path("images/marker-shadow.png") %>",
+  "/images/marker-shadow-2x.png": "<%= asset_path("images/marker-shadow-2x.png") %>"
+};
+
+L.extend(L.Icon.Default.prototype, {
+  _oldGetIconUrl: L.Icon.Default.prototype._getIconUrl,
+
+  _getIconUrl:  function (name) {
+    var url = this._oldGetIconUrl(name);
+    return L.Icon.Default.imageUrls[url];
+  }
+});
 
 L.Hash.prototype.parseHash = OSM.parseHash;
 L.Hash.prototype.formatHash = OSM.formatHash;