[OpenLayers-Users] SingleFile.js - small improvement in RegExp of function _getScriptLocation

Andreas Neumann a.neumann at carto.net
Wed Feb 16 11:45:53 EST 2011


 Hi Eric,

 Thank you for the hint - I'll go with option two.

 Andreas

 On Tue, 15 Feb 2011 09:03:11 +0100, Eric Lemoine wrote:
> On Mon, Feb 14, 2011 at 5:51 PM, Andreas Neumann 
> <a.neumann at carto.net> wrote:
>> Hi,
>>
>> While trying to optimize OpenLayers for deployment I noticed that 
>> OpenLayers
>> fails if the file is named OpenLayers.js.gz instead of just 
>> OpenLayers.js
>>
>> It is simple to fix:
>>
>> In file SingleFile.js, in function _getScriptLocation change:
>>
>> old:
>> var r = new RegExp("(^|(.*?\\/))(OpenLayers\.js)(\\?|$)"),
>>            s = document.getElementsByTagName('script'),
>>            src, m, l = "";
>>
>> new:
>> var r = new RegExp("(^|(.*?\\/))(OpenLayers\.js)(\.gz)*(\\?|$)"),
>>            s = document.getElementsByTagName('script'),
>>            src, m, l = "";
>>
>> note the additional '(\.gz)*'
>>
>> Could this be included in trunk so one can use either OpenLayers.js 
>> or
>> OpenLayers.js.gz?
>>
>> see ticket http://trac.osgeo.org/openlayers/ticket/3060
>
> Hi
>
> I can see two alternatives.
>
> #1 Write your own SingleFile.js:
>
> var OpenLayers = {
>     _getScriptLocation: function() {
>         return "path to your OpenLayers.js.gz";
>     }
> };
>
> #2 Do the following:
>
> - In your page's head add a <link> tag to OpenLayers'
> theme/default/style.css file,
> - Pass theme:null to the Map (and the OverviewMap)
> - Set OpenLayers.imgPath to the path to OpenLayers' img dir
>
> With these things OpenLayers won't need _getScriptLocation at all.
>
>
> I'd recommend #2.
>
> Cheers,

-- 
 --
 Andreas Neumann
 Böschacherstrasse 10A
 8624 Grüt (Gossau ZH)
 Switzerland


More information about the Users mailing list