[mapguide-users] RE: php to vb.net strict variables
Brad L
bradl at mai-eng.com
Fri Feb 16 12:38:44 EST 2007
I tried to post to this list earlier and am not sure if I did it correctly so
here goes take 2.
in vb.net try
Dim layers As MgReadOnlyLayerCollection = selection.GetLayers
if you are using visual studio you can hover over the method and it will
tell you what type of value is being returned. For example:
hovering over selection.GetLayers gives you a pop up that says "Public
Function Getlayers() as OSGeo.MapGuide.MGReadOnlyLayerCollection
This should help you get the correct object type most of the time.
Brad Leighninger
Mathews & Associates, Inc.
417-869-6009
ctallman wrote:
>
> I think I understand about half of this. However I think I'm one step
> before some of this. Here is my code that I'm trying to use.
>
> Dim selection As New MgSelection(map, xmlSelectString)
>
> Dim layers As MgLayerCollection
>
> layers = selection.GetLayers()
>
> This is where I'm getting the error: selection.GetLayers() however if I
> change it to read map.GetLayers() it works fine. Only thing is now its
> not looking at my selection its looking at the whole map, this is not
> what I'm looking for. I tried to change my variable type to
> MgLayerCollection as Chris suggested but this doesn't seem to work.
>
> I do see in the dev guide that MgMap::GetLayers() returns
> MgLayerCollection then from that collection I will be able to get the
> specific item I'm looking for.
> Am I getting the error because the selection doesn't exist yet?
>
> Chris
>
> ________________________________
>
> From: mapguide-users-bounces at lists.osgeo.org
> [mailto:mapguide-users-bounces at lists.osgeo.org] On Behalf Of Andy
> Morsell
> Sent: Friday, February 16, 2007 11:49 AM
> To: 'MapGuide Users Mail List'
> Subject: RE: [mapguide-users] php to vb.net strict variables
>
>
> Watch out for the type change in the API introduced with the release of
> 1.1.0 where you now have to use casts. This broke a couple of a my
> applications. See the readme at
> http://download.osgeo.org/mapguide/releases/1.1.0/ReleaseNotesMapGuideOp
> enSource-1.1.0.html
>
>
> New Base classes
>
>
> MgLayer, MgMap and MgSelection now have new superclasses; they are
> respectively MgLayerBase, MgMapBase and MgSelectionBase. No new methods
> have been added by this refactoring, but the methods are now distributed
> between the subclass and superclass. For .NET or Java applications, if
> the following APIs are used then casts will need to be done:
>
> When using
>
> * MgLayerCollection.GetItem(Int32 index)
> * MgLayerCollection.GetItem(CREFSTRING name)
> * MgReadOnlyLayerCollection.GetItem(Int32 index)
>
> the returned object has type MgLayerBase. This object can always be
> safely cast to a MgLayer object.
>
> For example,
> MgLayer myLayer = myCollection.GetItem(i);
> needs to be changed to
> MgLayer myLayer = myCollection.GetItem(i) as MgLayer; // for .NET
> MgLayer myLayer = (MgLayer)myCollection.GetItem(i); // for Java
>
> When using
>
> * MgMapCollection.GetItem(Int32 index)
> * MgMapCollection.GetItem(CREFSTRING name)
>
> the returned object has type MgMapBase. This object can always be safely
> cast to a MgMap object.
>
> Note that where a MgMapBase, MgLayerBase or MgSelectionBase is the type
> of a parameter to a method, the respective objects of type MgMap,
> MgLayer and MgSelection can be used in their place.
>
> Andy Morsell, P.E.
> President
> Spatial Integrators, Inc.
> 509-466-3959
> amorsell at SpatialGIS.com
> http://www.SpatialGIS.com <http://www.spatialgis.com/>
>
>
>
> ________________________________
>
> From: mapguide-users-bounces at lists.osgeo.org
> [mailto:mapguide-users-bounces at lists.osgeo.org] On Behalf Of Chris
> Gountanis
> Sent: Friday, February 16, 2007 8:29 AM
> To: 'MapGuide Users Mail List'
> Subject: RE: [mapguide-users] php to vb.net strict variables
>
>
>
> You are going to have to set layers as an MgLayerCOllection object then
> loop through that to create array if needed. The collection itself is an
> array of values so that might be all your looking for, Use the ASP.NET
> examples from the OSGEO site for a detailed look at a real working
> example.
>
>
>
> For example in C#: MgLayerCollection layers = map.GetLayers();
>
>
>
> You can get info on a single layer with: MgLayer layer =
> layers.GetItem("Parcels"); or loop though the whole collection.
>
>
>
> This is all explained in the dev manual as well as examples on the site.
> Helped me out for sure.
>
>
>
>
>
> Chris
>
>
>
>
>
> ________________________________
>
> From: mapguide-users-bounces at lists.osgeo.org
> [mailto:mapguide-users-bounces at lists.osgeo.org] On Behalf Of Chris
> Tallman
> Sent: Friday, February 16, 2007 10:19 AM
> To: MapGuide Users Mail List
> Subject: [mapguide-users] php to vb.net strict variables
>
>
>
> Ok I'm taking my first shot at converting some php code to asp.net vb.
> I'm getting stumped on the GetLayers.
>
>
>
> Here is the php code.
>
> $layers = $selection->GetLayers();
>
>
>
> Here is what I'm trying to convert it to.
> Dim layers As ArrayList
> layers = selection.GetLayers()
>
>
>
> Array list is wrong I'm just not sure what to declare the layers
> variable. I tried MGLayers but that was not right either.
>
> So far everything I've tried I get
>
> 'Value of Type 'OSGeo.Mapguide.MgReadOnlyLayerCollection' cannot be
> converted to'
>
> then whatever type I've tried to declare the layers variable.
>
>
>
> I know this command GetLayers is supposed to be getting a list of the
> selected layers, and it looks like it itemizes them like an array hence
> the array type.
>
>
>
> If anyone has any suggestions they would be appreciated.
>
>
>
> Thanks,
>
>
> Chris Tallman
> 260.356.9074
>
>
>
>
>
> _______________________________________________
> mapguide-users mailing list
> mapguide-users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/mapguide-users
>
>
--
View this message in context: http://www.nabble.com/php-to-vb.net-strict-variables-tf3240387s16610.html#a9008962
Sent from the MapGuide Users mailing list archive at Nabble.com.
More information about the mapguide-users
mailing list