[GIS] How to create the own minifed openlayers js file

openlayers-2

I want to create my own minified openlayers js file with only the relevant classes my app used (including some custom class).

Is there a way to know by using the full openlayers.js file which are the ones I need to include in my custom build (instead doing trial and error and start deleting files and see which breaks my app) ?

Best Answer

I've always successfully used Custom Builds Profiles to create custom OpenLayers Deployments.

There is a detailed explanation available here: Custom build Profiles

These are the steps I follow:

  • Go through my Code and see which classes I'm using. Basically look for any class which you are using like new OpenLayers.ClassName(). Add these classes to the profile.
  • The builder will look through the OpenLayers Code and automatically include those dependencies in the build.
  • The only exception to this is the Vector Classes. If you are using Vector Layers, you need to provide all three renderes, since OpenLayers dynamically selects the appropriate renderer.