Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[udig-devel] Re: MapGraphics and Layer

I figured it out - problem on my end with the extension point.


"Andy Czerwonka" <czerwonka@xxxxxxxxxxxxxxxx> wrote 
in message news:ep557g$vl6$1@xxxxxxxxxxxxx...
> In one of the more recent 1.1.x releases, my code broke.  I'm creating a 
> layer with a MapGraphic, but now I'm not able to create that layer.  The 
> code looks like this... (it falls out on the assert about halfway down)
>
>    public void createGpsLayer() {
>        Map map = ApplicationGISInternal.getActiveMap();
>
>        try {
>            IGeoResource gpsDataResource = null;
>            URL url = new URL(MapGraphicService.SERVICE_URL, "#" + 
> GpsMapGraphic.ID); //$NON-NLS-1$
>            List<IResolve> matches = 
> CatalogPlugin.getDefault().getLocalCatalog().find(url,
>                new NullProgressMonitor());
>            if (!matches.isEmpty())
>                gpsDataResource = (IGeoResource) matches.get(0);
>            if (gpsDataResource == null) {
>                List<IService> results = 
> CatalogPlugin.getDefault().getServiceFactory()
>                    .acquire(url);
>                for (IGeoResource resource : results.get(0).members(new 
> NullProgressMonitor())) {
>                    if 
> (resource.getIdentifier().getRef().equals(url.getRef())) {
>                        gpsDataResource = resource;
>                        break;
>                    }
>                }
>            }
>            assert null != gpsDataResource : "Somethig is wrong" // it 
> falls our here...
>            _gpsLayer = map.getLayerFactory().createLayer(gpsDataResource);
>            _gpsLayer.setName(LAYER_NAME);
>            _gpsLayer.setSelectable(true);
>            int top = map.getMapLayers().size();
> 
> map.sendCommandSync(BasicCommandFactory.getInstance().createAddLayer(_gpsLayer, 
> top));
>            _mapGraphic = _gpsLayer.getResource(GpsMapGraphic.class, null);
> 
> Activator.getDefault().getModel().addEventCollectionListener(_mapGraphic);
>            startRefresher();
>        } catch (MalformedURLException e) {
>            AppLogger.log(e);
>        } catch (IOException e) {
>            AppLogger.log(e);
>        }
>
>    }
>
> Help appreciated...
>
> 





Back to the top