Tuesday, May 6, 2008

How to load a mapgraphic layer programmatically

As Jesse states: "A mapgraphic is just a georesource. It just so happens that it is loaded into the catalog automatically. Search the catalog for MapGraphicService.SERVICE_URL."

And so we do:

List mapgraphics = CatalogPlugin.getDefault().getLocalCatalog().find(
MapGraphicService.SERVICE_URL, null);
List members = mapgraphics.get(0).members(null);
for( IResolve resolve : members ) {
if (resolve.canResolve(GeonotesMapGraphic.class)) {
ApplicationGIS.addLayersToMap(ApplicationGIS.getActiveMap(), Collections
.singletonList(resolve.resolve(IGeoResource.class, null)), 0);

No comments: