OpenLayers attempts to load default CSS file even with theme: null
I'm using OpenLayers with Meteor, a highly dynamic interactive web framework (http://www.meteor.com/). With the way Meteor works, we can't just stick a bunch of JS and CSS on the page, so I'm trying to control the way OpenLayers loads its images and themes.
I am trying to specify the ImgPath manually as well as adding a manual CSS link. I am also explicitly telling OpenLayers to not attempt to load the CSS with Javascript:
<link rel="stylesheet" href="http://dev.openlayers.org/releases/OpenLayers-2.13.1/theme/default/style.css" type="text/css">
OpenLayers.ImgPath = "http://dev.openlayers.org/releases/OpenLayers-2.13/img/";
map = new OpenLayers.Map 'map',
layers: [mapLayer, vectorLayer, cursorLayer]
maxExtent: extent
restrictedExtent: extent
resolutions: resolutions
serverResolutions: serverResolutions
theme: null # don't attempt to load theme from default path
However, when my app runs, OL attempts to load the default CSS link relatively anyway. This results in a Meteor application bundle being served, because of how Meteor works:
Resource interpreted as Stylesheet but transferred with MIME type text/html: "http://192.168.56.101:3000/client/compatibility/theme/default/style.css".
Is there any way to turn off the auto theme loading more forcefully or is this a bug?
Try :
theme: false
or simply omit it.
Both theme: null and theme: false are giving the same behavior, although I discovered that this may be due to the overview map loading the theme a second time. Will look into it.
I can confirm, OverviewMap control is loading default theme. You have to specify theme: null for OverviewMap options, I can send you sample tomorrow. I had the same problem and just manged to solve it.
I'm doing this for both Map and OverviewMap but the style css load is still showing up. theme: false doesn't work either. What else could be doing it?
map = new OpenLayers.Map 'map',
layers: # ...
# ... other properties
theme: null # don't attempt to load theme from default path
controls: # ...
map.addControl(new OpenLayers.Control.OverviewMap
theme: null # again, don't load theme
)
This is using 2.13.1.

You should send that to the mapOptions property
map.addControl(new OpenLayers.Control.OverviewMap
mapOptions:
theme: null
)
That's convoluted. OverviewMap should inherit options like this from the normal map. Oh well...
Since you are setting this property for an instance of OpenLayers.Map, there is no way an unrelated instance of OpenLayers.Control.OverviewMap can inherit this, right?
an overviewmap always has a relation to a map, since it is added as a control to the map
Good point, @mprins .
So when the mapOptions of the Control.OverviewMap do not specify theme, we should not default to something, but to the value of theme of the OpenLayers.Map it is bound to, right?
I'd be in favor of a change like the one above.
I'm not unhappy with the way it is now (since I learned from the code), but to me it seems logical to inherit things like from theme, projection, units etc. from the O.Map containing the control ( I know some of these may actually be Layer props)
In my javascript code within meteor client, how can i acess the OSM using openlayers? I have added the package for openlayers but my javascript function is not recognising the openlayer object
var osm = new OpenLayers.Layer.OSM("OpenLayers OSM"); says unresolved variable if i hover on openlayers