[mapguide-users] Change map scale or get min and max scale from layer

Kenneth Skovhede, GEOGRAF A/S ks at geograf.dk
Tue Oct 14 08:02:56 EDT 2008


IIRC, IsVisible() is the same as GetVisible(), which is a property that 
determines if the layer is visible.
If the layer is "visible", it will be displayed, but only appears in the 
map at predefined scale ranges.

The scale ranges are actually present in the layer object, but not 
accesible from the API.
You have to read out the LayerDefinition ResourceIdentifier, load the 
xml from the LayerDefinition, and find the <VectorScaleRange> tags:
  <VectorScaleRange>
      <MinScale>0</MinScale>
      <MaxScale>100</MaxScale>
 </VectorScaleRange>

Be aware that both <MinScale> and <MaxScale> may be missing, in which 
case they are 0 and inifinite respectively.

Regards, Kenneth Skovhede, GEOGRAF A/S



Lukas Hybner skrev:
> Hi all,
>
> I have a problem when I show tree of layers. I need to know if the layer
> is Visible or not. 
>
> For Example client send scale=5000000 and some layers is visible from 1
> to 4000. When I want to know if the layers is visible, I use method
> isVisible(). This method return always true because map.getViewScale()
> returns 1.0 (not 5000000).
>
> My code is (in jsp):
>
> String mapDefinition = "some map definition";
> MgMap map = new MgMap();
> MgResourceIdentifier resId = new MgResourceIdentifier(mapDefinition);
> String mapName = resId.GetName();
> map.Create(resourceSrvc, resId, mapName);
>
> MgGeometryFactory factory = new MgGeometryFactory();
> MgCoordinate centerCoord = factory.CreateCoordinateXY(centerx,centery); 
>
>
> //here is scale property from client
> MgByteReader mgImage = renderingSrvc.RenderMap( map, null, centerCoord,
> scale,width, height, color, "JPG" );
>
> out.println(map.GetViewScale()); //returns 1.0
>
> MgLayerCollection layers = map.GetLayers();
> for (int i = 0; i < layers.GetCount(); ++i)
> 	out.println( (layers.GetItem(i).isVisible ? "on" : "off") );
> //this write on
>
>
> How can I change scale in object map? Or is some other solution? Or can
> I read from layer object min and max scale?
>
> Lukas Hybner
>
>
> _______________________________________________
> mapguide-users mailing list
> mapguide-users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/mapguide-users
>   


More information about the mapguide-users mailing list