[mapguide-users] Zoom to feature using ajaxviewer

Saurabh Gupta. Noida Saurabh-G at hcl.com
Thu Sep 6 09:04:13 PDT 2012


hello Zac,

if pk is primary key.. then i would say that this layer is a separate shape file which is not having any pk because its not required.

Regards



________________________________________
From: mapguide-users-bounces at lists.osgeo.org [mapguide-users-bounces at lists.osgeo.org] On Behalf Of Zac Spitzer [zac.spitzer at gmail.com]
Sent: Thursday, September 06, 2012 7:24 PM
To: MapGuide Users Mail List
Subject: Re: [mapguide-users] Zoom to feature using ajaxviewer

does your feature source have a pk?

On Thu, Sep 6, 2012 at 10:05 PM, veer-singh <veer-singh at hcl.com> wrote:
> Hello Lists..
>
> Please help me out in this.
>
> I am trying to zoom to a feature based on feature attribute value query.. I
> am not selecting any feature on map. i just want to zoomto feature based on
> my hardcoded query, here in below function you can assume fixed hardcoded
> values for layername and selection which is actually a featid of feature.
>
> i am using following function at server side...
>
>  public String OutputSelectionInHTML(MgMap map, MgFeatureService
> featureService, string layerName, string selection, MgResourceService
> resService, string mgMapName)
>     {
>         MgSelection mapSelection = new MgSelection(map);
>         mapSelection.Open(resService, mgMapName);
>         //MgReadOnlyLayerCollection layers = mapSelection.GetLayers();
>         MgLayerCollection layers = map.GetLayers();
>         String outString = null;
>         MgFeatureReader featReader = null;
>         if (layers != null)
>         {
>             for (int i = 0; i < layers.GetCount(); i++)
>             {
>                 MgLayerBase nextLayer = layers.GetItem(i);
>                 //MgLayer layer = (MgLayer)layers.GetItem(i);
>                 if (nextLayer != null && (nextLayer.GetName() == layerName))
>                 {
>                     String layerClassName = nextLayer.GetFeatureClassName();
>                     String selectString = "FeatId = " + selection;
>                     String layerFeatureIdString =
> nextLayer.GetFeatureSourceId();
>                     MgResourceIdentifier layerResId = new
> MgResourceIdentifier(layerFeatureIdString);
>                     MgFeatureQueryOptions queryOptions = new
> MgFeatureQueryOptions();
>                     queryOptions.SetFilter(selectString);
>                     featReader = featureService.SelectFeatures(layerResId,
> layerClassName.Split(':')[1].ToString(), queryOptions);
>                     while (featReader.ReadNext())
>                     {
>                         //MgByteReader
> mgbyte=featReader.GetGeometry(MgPropertyType.Feature);
>
>                         //mapSelection.AddFeatures(nextLayer, featReader,
> mapSelection.GetSelectedFeaturesCount(nextLayer,
> layerClassName.Split(':')[1].ToString()));
>                         mapSelection.AddFeatures(nextLayer, featReader, 0);
>                     }
>                      //get XML from selection
>                     string selectionXML = mapSelection.ToXml();
>
>                     //get center
>                     double selectionCenterX =
> mapSelection.GetExtents(featureService).GetLowerLeftCoordinate().GetX() +
> mapSelection.GetExtents(featureService).GetWidth() / 2;
>                     double selectionCenterY =
> mapSelection.GetExtents(featureService).GetLowerLeftCoordinate().GetY() +
> mapSelection.GetExtents(featureService).GetHeight() / 2;
>
>                     outString = "zoom~" + selectionXML + "~" +
> selectionCenterX + "~" + selectionCenterY;
>                                    }
>             }
>         }
>         ClientScript.RegisterStartupScript(this.GetType(), "page", "");
>   }
>
> following at client side
>
>
>
>
>
> -----
> VEER HCLTECH,INDIA
> --
> View this message in context: http://osgeo-org.1560.n6.nabble.com/Zoom-to-feature-using-ajaxviewer-tp5000178.html
> Sent from the MapGuide Users mailing list archive at Nabble.com.
> _______________________________________________
> mapguide-users mailing list
> mapguide-users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/mapguide-users



--
Zac Spitzer
Solution Architect / Director
Ennoble Consultancy Australia
+61 405 847 168
_______________________________________________
mapguide-users mailing list
mapguide-users at lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/mapguide-users


::DISCLAIMER::
----------------------------------------------------------------------------------------------------------------------------------------------------

The contents of this e-mail and any attachment(s) are confidential and intended for the named recipient(s) only.
E-mail transmission is not guaranteed to be secure or error-free as information could be intercepted, corrupted,
lost, destroyed, arrive late or incomplete, or may contain viruses in transmission. The e mail and its contents
(with or without referred errors) shall therefore not attach any liability on the originator or HCL or its affiliates.
Views or opinions, if any, presented in this email are solely those of the author and may not necessarily reflect the
views or opinions of HCL or its affiliates. Any form of reproduction, dissemination, copying, disclosure, modification,
distribution and / or publication of this message without the prior written consent of authorized representative of
HCL is strictly prohibited. If you have received this email in error please delete it and notify the sender immediately.
Before opening any email and/or attachments, please check them for viruses and other defects.

----------------------------------------------------------------------------------------------------------------------------------------------------



More information about the mapguide-users mailing list