I'm new to GIS and I would like to know if anybody could give me a quick example of using GeoWebCache with Google maps tiles.
[GIS] Using GeoWebCache to cache Google maps tiles
geoservergeowebcachegoogle mapstilecachetiles
Related Solutions
As per the documentation, switching from WMS to GeoWebCache only requires a URL change from:
/geoserver/wms <- direct WMS
/geoserver/gwc/service/wms <- geocached wms
and you're good to go, no need to switch WMTS. BTW, GeoWebCache requires all tiles be 256x256.
You can also seed the cache from the GeoCache home that can be reached from the Geoserver admin app.
What you have found is something in the OpenLayers sand box, which is an environment where OpenLayers contributors can add their own custom layers, controls, etc. Sometimes things created in the sand box work their way through to the core distribution.
However, it is simple to take what has been created and add it to your OpenLayers build. First, you need to get the source file for the GeoWebCache layer:
http://dev.openlayers.org/sandbox/tschaub/gwc/lib/OpenLayers/Layer/GeoWebCache.js
Save that somewhere locally. Now you need to decide whether you want to build the script into your main OpenLayers library or whether you just want to include it on your page.
Including on your page
The simplest approach is to include it on your page, so just add the script to your HTML header:
<head>
<title>Your Page Title Here</title>
<script src="path/to/OpenLayers.js" type="text/javascript"></script>
<script src="path/to/GeoWebCache.js" type="text/javascript"></script>
<!-- Other scripts, meta tags, CSS, etc -->
</head>
Now you can use the GeoWebCache layer in your script:
new OpenLayers.Layers.GeoWebCache({
url: "http://path/to/web/accessible/cache"
});
If you place multiple copies of your cache in different locations then you can supply the url
property with an array of urls, this will give you greater throughput on the client as it allows your browser to create more concurrent requests for tiles.
Building into your OpenLayers library
This is a little more involved but has the benefit of making things a little easier to port around and also will keep your code a little cleaner. within the OpenLayers source directory there is a Python build script that allows you to create custom builds of OpenLayers. This can be useful for example to create a small library of only the OpenLayers components you need, rather than the full build.
To add the GeoWebCache layer into the OpneLayers build you need to do the following.
- Download the OpenLayers source
- Copy the GeoWebCache.js file into the folder /lib/OpenLayers/Layer
- Perform an OpenLayers build using the Python build scripts
Building OpenLayers is simply a case of opening a command prompt (assuming Windows), and doing something like:
D:
cd Development\OpenLayers-2.13.1\build
python build.py full OpenLayers-GeoWebCache.js
Note that this assumes you extracted the OpenLayers source to a folder called D:\Development\OpenLayers-2.13.1 so you'll need to change that to your folder. The build command itself can be configured to use a different compression mechanism (the default is jsmin) and the output file can also be set - in this case we called it OpenLayers-GeoWebCache.js.
Now copy that file to where your HTML page is and include it like you would the normal OpenLayers library.
You can also customise the build by creating and using a build script. Note the full
argument supplied to the build.py
script - this instructs the script to do a full OpenLayers build. You can change this to a customised build by specifying a name and creating a corresponding build script. For example, suppose you only wanted a minimal OpenLayers build including the GeoWebCache layer. You would create a file called minimal-geowebcache.cfg
in the build folder. The content of the file should be:
[first]
[last]
[include]
OpenLayers/Map.js
OpenLayers/Kinetic.js
OpenLayers/Projection.js
OpenLayers/Layer/Vector.js
OpenLayers/Layer/OSM.js
OpenLayers/Layer/Bing.js
OpenLayers/Layer/WMS.js
OpenLayers/Layer/Google/v3.js
OpenLayers/Layer/GeoWebCache.js
OpenLayers/Popup/FramedCloud.js
OpenLayers/Control/Navigation.js
OpenLayers/Control/Zoom.js
OpenLayers/Control/Attribution.js
OpenLayers/Control/SelectFeature.js
OpenLayers/Control/Panel.js
OpenLayers/Control/LayerSwitcher.js
OpenLayers/Renderer/SVG.js
OpenLayers/Renderer/VML.js
OpenLayers/Format/GeoJSON.js
OpenLayers/Protocol/HTTP.js
OpenLayers/Strategy/Fixed.js
OpenLayers/Strategy/BBOX.js
OpenLayers/StyleMap.js
OpenLayers/Rule.js
OpenLayers/Filter/Comparison.js
OpenLayers/Filter/Logical.js
[exclude]
Then you can perform a build using this configuration with the command:
python build.py minimal-geowebcache OpenLayers.js
This will create a much smaller OpenLayers library that you can include in your page. Just make sure you build the library with all the bits of OpenLayers you are using!
Best Answer
check these links:
http://geowebcache.org/docs/current/services/gmaps.html
How to setup GeoWebCache to produce same grid as GoogleMaps?
http://fuzzytolerance.info/blog/google-earth-api-integration-via-geowebcache/
Hope these links will help you.