Hello everybody,<br><br>I am trying to query tiles from the sample Sheboygan map in java, at the following line:<br><br>tileService.GetTile(mapDefid, "Tiled Layers", 1, 1, 1);<br><br>i get a org.osgeo.mapguide.MgIndexOutOfRangeException: Index is out of range. exception.<br>
<br>I tend to think that the second parameter is wrong, however i cannot figure out what to put here.<br><br>The complete code:<br><br>try {<br> MgResourceIdentifier mapDefid = new MgResourceIdentifier(<br> "Library://Samples/Sheboygan/Maps/Sheboygan.MapDefinition");<br>
try {<br> MapGuideJavaApi.MgInitializeWebTier("C:\\webconfig.ini");<br> } catch (Exception ex) {<br> ex.printStackTrace();<br> }<br> MgUserInformation userInfo = new MgUserInformation("Anonymous", "");<br>
MgSite site = new MgSite();<br> site.Open(userInfo);<br> String sessionId = site.CreateSession();<br> <a href="http://log.info">log.info</a>(String.format("Session id: " + sessionId));<br>
site.Close();<br> MgSiteConnection siteConnection = new MgSiteConnection();<br> //MgUserInformation mgUserInformation = new MgUserInformation(this.sessionId);<br> siteConnection.Open(userInfo);<br>
MgResourceService service = (MgResourceService) siteConnection<br> .CreateService(MgServiceType.ResourceService);<br> List<MgMap> maps = new ArrayList<MgMap>();<br> MgMap map;<br>
maps.add(map = new MgMap());<br> map.Create(service, mapDefid, "MyMap");<br> MgRenderingService renderingService = (MgRenderingService) siteConnection<br> .CreateService(MgServiceType.RenderingService);<br>
MgFeatureService featureService = (MgFeatureService) siteConnection<br> .CreateService(MgServiceType.FeatureService);<br> MgTileService tileService = (MgTileService) siteConnection<br>
.CreateService(MgServiceType.TileService);<br> int x = tileService.GetDefaultTileSizeX();<br> int y = tileService.GetDefaultTileSizeY();<br> log.debug(String.format("Tile size; width: %d height: %d", x, y));<br>
// this.tileService.GetTile(map, "LayersDrawn", 0, 0);<br> tileService.GetTile(mapDefid, "Tiled Layers", 1, 1, 1);<br> /**<br> * Make all layers visible<br>
*/<br> for (int i = 0; i < map.GetLayers().GetCount(); i++) {<br> MgLayerBase layer = map.GetLayers().GetItem(i);<br> layer.SetVisible(true);<br> <a href="http://log.info">log.info</a>("Layer name: " + layer.GetName() + " was made visible");<br>
}<br> } catch (MgException ex) {<br> <a href="http://log.info">log.info</a>(ex);<br> }<br><br>