does your feature source have a pk? On Thu, Sep 6, 2012 at 10:05 PM, veer-singh <[email protected]> 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 > [email protected] > http://lists.osgeo.org/mailman/listinfo/mapguide-users
-- Zac Spitzer Solution Architect / Director Ennoble Consultancy Australia +61 405 847 168 _______________________________________________ mapguide-users mailing list [email protected] http://lists.osgeo.org/mailman/listinfo/mapguide-users
