[OSM-dev] Fwd: Local Tiles on JSP + Tomcat issue

Reshma Maner r_maner at transworld-compressor.com
Wed Aug 22 08:45:45 BST 2012


  Hi,

I have set up osm2pgsql,mapnik on ubuntu server. I have also generated 
tiles locally.
Now I want to display these tiles on map in a JSP page. I am using open 
layers.
I have been trying it. The code works fine in html, but if same thing I 
do in a jsp page, it does not open map tiles. Only pink canvas is 
displayed. On rightclick, it displayes map tile path as 
"/LocalFolder///.png". Error screen shot is attached. And source code is 
given below.

Please let me know what is the procedure I should follow to display 
local map on a jsp page(Tomcat server),

Code:


function init() {

             map = new OpenLayers.Map ($('map'), {
                 maxExtent: new OpenLayers.Bounds(-180,-90,180,90),
                 minExtent: new OpenLayers.Bounds(-1,-1,1,1),
                 'maxResolution': 360/512,
                 numZoomLevels: 4,
                 units: 'dd',
                 projection: new OpenLayers.Projection("EPSG:900913"),
               //  displayProjection: new
OpenLayers.Projection("EPSG:4326")
             displayProjection: new OpenLayers.Projection("EPSG:900913")
             } );

             layerMapnik = new OpenLayers.Layer.OSM.Mapnik("Mapnik");
             layerMapnik.setOpacity(0.4);
           //  map.addLayer(layerMapnik);

             layerCycleMap = new
OpenLayers.Layer.OSM.CycleMap("CycleMap");
             layerCycleMap.setOpacity(0.4);
           //  map.addLayer(layerCycleMap);

             // This is the layer that uses the locally stored tiles
            var newLayer = new OpenLayers.Layer.OSM("Localhost",
"IndiaMap/${z}/${x}/${y}.png", {numZoomLevels: 4, alpha: true,
isBaseLayer: true});
             //var newLayer = new OpenLayers.Layer.OSM("LocalTiles",
"IndiaMap/${0}/${0}/${0}.png", {numZoomLevels: 10, alpha: true,
isBaseLayer: true});
  			//layerLocalMap = new OpenLayers.Layer.OSM.LocalMap("LocalMap");
  		//	layerLocalMap.setOpacity(0.4);
  		//newLayer.setOpacity(0.6);
             map.addLayer(newLayer);
			// This is the end of the layer
  			

  	            var switcherControl = new
OpenLayers.Control.LayerSwitcher();
	            map.addControl(switcherControl);
	            switcherControl.maximizeControl();

             if( ! map.getCenter() ){
                 var lonLat = new OpenLayers.LonLat(lon,
lat).transform(new OpenLayers.Projection("EPSG:4326"),
map.getProjectionObject());
                 map.setCenter (lonLat, zoom);
             }
         }





-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/dev/attachments/20120822/72ed094a/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: maperror.png
Type: image/png
Size: 97193 bytes
Desc: not available
URL: <http://lists.openstreetmap.org/pipermail/dev/attachments/20120822/72ed094a/attachment-0001.png>


More information about the dev mailing list