]> git.openstreetmap.org Git - rails.git/blob - app/assets/javascripts/openlayers.js.erb
Fix loading of blank tiles on some browsers to use the asset pipeline
[rails.git] / app / assets / javascripts / openlayers.js.erb
1 //= require OpenLayers
2 //= require OpenStreetMap
3
4 OpenLayers.Util.imageURLs = {
5     "img/404.png": "<%= asset_path 'img/404.png' %>",
6     "img/blank.gif": "<%= asset_path 'img/blank.gif' %>",
7     "img/cloud-popup-relative.png": "<%= asset_path 'img/cloud-popup-relative.png' %>",
8     "img/drag-rectangle-off.png": "<%= asset_path 'img/drag-rectangle-off.png' %>",
9     "img/drag-rectangle-on.png": "<%= asset_path 'img/drag-rectangle-on.png' %>",
10     "img/east-mini.png": "<%= asset_path 'img/east-mini.png' %>",
11     "img/layer-switcher-maximize.png": "<%= asset_path 'img/layer-switcher-maximize.png' %>",
12     "img/layer-switcher-minimize.png": "<%= asset_path 'img/layer-switcher-minimize.png' %>",
13     "img/marker-blue.png": "<%= asset_path 'img/marker-blue.png' %>",
14     "img/marker-gold.png": "<%= asset_path 'img/marker-gold.png' %>",
15     "img/marker-green.png": "<%= asset_path 'img/marker-green.png' %>",
16     "img/marker.png": "<%= asset_path 'img/marker.png' %>",
17     "img/measuring-stick-off.png": "<%= asset_path 'img/measuring-stick-off.png' %>",
18     "img/measuring-stick-on.png": "<%= asset_path 'img/measuring-stick-on.png' %>",
19     "img/north-mini.png": "<%= asset_path 'img/north-mini.png' %>",
20     "img/panning-hand-off.png": "<%= asset_path 'img/panning-hand-off.png' %>",
21     "img/panning-hand-on.png": "<%= asset_path 'img/panning-hand-on.png' %>",
22     "img/slider.png": "<%= asset_path 'img/slider.png' %>",
23     "img/south-mini.png": "<%= asset_path 'img/south-mini.png' %>",
24     "img/west-mini.png": "<%= asset_path 'img/west-mini.png' %>",
25     "img/zoombar.png": "<%= asset_path 'img/zoombar.png' %>",
26     "img/zoom-minus-mini.png": "<%= asset_path 'img/zoom-minus-mini.png' %>",
27     "img/zoom-plus-mini.png": "<%= asset_path 'img/zoom-plus-mini.png' %>",
28     "img/zoom-world-mini.png": "<%= asset_path 'img/zoom-world-mini.png' %>"
29 };
30
31 OpenLayers.Util.origCreateDiv = OpenLayers.Util.createDiv;
32
33 OpenLayers.Util.createDiv = function(id, px, sz, imgURL, position, 
34                                      border, overflow, opacity) {
35     imgURL = OpenLayers.Util.imageURLs[imgURL] || imgURL;
36
37     return OpenLayers.Util.origCreateDiv(id, px, sz, imgURL, position, 
38                                          border, overflow, opacity);
39 };
40
41 OpenLayers.Util.origCreateImage = OpenLayers.Util.createImage;
42
43 OpenLayers.Util.createImage = function(id, px, sz, imgURL, position, border,
44                                        opacity, delayDisplay) {
45     imgURL = OpenLayers.Util.imageURLs[imgURL] || imgURL;
46
47     return OpenLayers.Util.origCreateImage(id, px, sz, imgURL, position,
48                                            border, opacity, delayDisplay);
49 };
50
51 OpenLayers.Util.origModifyAlphaImageDiv = OpenLayers.Util.modifyAlphaImageDiv;
52
53 OpenLayers.Util.modifyAlphaImageDiv = function(div, id, px, sz, imgURL, 
54                                                position, border, sizing, 
55                                                opacity) {
56     imgURL = OpenLayers.Util.imageURLs[imgURL] || imgURL;
57
58     return OpenLayers.Util.origModifyAlphaImageDiv(div, id, px, sz, imgURL, 
59                                                    position, border, sizing, 
60                                                    opacity);
61 };
62
63 OpenLayers.Tile.Image.clear = function() {
64     if (this.imgDiv) {
65         this.hide();
66         if (OpenLayers.Tile.Image.useBlankTile) { 
67             this.imgDiv.src = "<%= asset_path 'img/blank.gif' %>";
68         }    
69     }
70 };