Community of VE/MapPoint Users and Developers
This is a discussion on Enjoy Mobile GIS (2) Using C# to edit the electronic map in your mobile phone within the Other Mapping Platforms forums, part of the Map Forums category; Foreword: This article is the extension of << Enjoy Mobile GIS(1) Using C# to create a GIS program of mobile ...
| |||||||
| Register | Blogs | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| |||
| Some download for this article: code: myHiMapAdvanced.zip , map file: maps.zip , demo animation: myHiMapVideo2.gif . I. System requirements. Development Environment:: Windows XP, .NET Compact Framework 2.0, Windows Mobile 5 SDK, HiMap Beta1 runtime Run-time Environment: DOPOD D600 mobile phone(ARM CPU) (Windows Mobile 5.0) II.Function List: 1. Draw Geometry 2. Edit Geometry 3. Delete Geometry 4. Edit Property ![]() III.About the realization: First, we will have a brief introduction of these basic function. For more description of functions, please consult <<HiMap Help>> //1.Create a new feature //Get a layer IFeatureLayer lyr = (IFeatureLayer)mapControl1.Map.GetLayer(0); //Get a featureClass of the layer IFeatureClass cls = (IFeatureClass)lyr.Class; //Create a feature for this featureClass IFeature feat = cls.CreateFeature(); //Save the change feat.Save(); //2.Delete a feature //Get a layer IFeatureLayer lyr = (IFeatureLayer)mapControl1.Map.GetLayer(0); //Get a featureClass of layer IFeatureClass cls = (IFeatureClass)lyr.Class; //Create a query filter of featureClass IQueryFilter qf=new QueryFilterClass(); //Setup query condition qf.WhereClause="id =1"; //Query data IFeatureCursor cur = cls.Search(qf); //Get the feature of query result IFeature feat = cur.Next(); //Delete a feature if (feat != null) { cls.DeleteFeature(feat); } //3.Update the value of a feature //First of all, get a layer IFeatureLayer lyr = (IFeatureLayer)mapControl1.Map.GetLayer(0); //Get a featureClass IFeatureClass cls = (IFeatureClass)lyr.Class; //Create a filter of query IQueryFilter qf=new QueryFilterClass(); //Setup the condition of query qf.WhereClause="id =1"; //Query data IFeatureCursor cur = cls.Search(qf); //Get the feature of query result IFeature feat = cur.Next(); if (feat != null) { //update the value "test data" to the field "name" feat.SetValue(cls.Fields.FindField("name"), "test data"); //save change feat.Save(); } //4.Update the geometry of a feature //Get a layer first IFeatureLayer lyr = (IFeatureLayer)mapControl1.Map.GetLayer(0); //Get a featureClass IFeatureClass cls = (IFeatureClass)lyr.Class; //Create a query filter IQueryFilter qf=new QueryFilterClass(); //Setup query condition qf.WhereClause="id =1"; //Query data IFeatureCursor cur = cls.Search(qf); //Get the feature of query result IFeature feat = cur.Next(); if (feat != null) { //Because the layer is a line type layer, so we use the IPolyling to get the geometry HiMap.Geometry.IPolyline line = (HiMap.Geometry.IPolyline)feat.Shape; IPointCollection chline = (IPointCollection)line; //Create some points(the LGT and LTT are for test only) IPoint pt1 = new PointClass(); pt1.X = "111.2345556"; pt1.Y = "23.2345556"; IPoint pt2 = new PointClass(); pt2.X = "112.2345556"; pt2.Y = "23.3345556"; //Add points to the line chline.AddPoint(pt1); chline.AddPoint(pt2); //Give the shape value of updated to the feature feat.Shape = (IGeometry)line; //Save change feat.Save(); } //5.Add parts to ployline and polygon //Get a layer IFeatureLayer lyr = (IFeatureLayer)mapControl1.Map.GetLayer(0); //Get a featureClass IFeatureClass cls = (IFeatureClass)lyr.Class; //Create a query filter IQueryFilter qf=new QueryFilterClass(); //Setup condition of query filter qf.WhereClause="id =1"; //Query data IFeatureCursor cur = cls.Search(qf); //Get a feature by query IFeature feat = cur.Next(); if (feat != null) { //Because the layer is a line type layer, so we use the IPolyling to get the geometry HiMap.Geometry.IPolyline line = (HiMap.Geometry.IPolyline)feat.Shape; //Create a new line IPointCollection chline = new PolylineClass(); //Create points for new the line(test data too) IPoint pt1 = new PointClass(); pt1.X = "111.2345556"; pt1.Y = "23.2345556"; IPoint pt2 = new PointClass(); pt2.X = "112.2345556"; pt2.Y = "23.3345556"; //Add points to the new line chline.AddPoint(pt1); chline.AddPoint(pt2); HiMap.Geometry.IGeometryCollection geoColl = (HiMap.Geometry.IGeometryCollection)line; //Add the new line to original line geoColl.AddGeometry((IGeometry)chline); //Give the value of geometry to feature feat.Shape = (IGeometry)line; //Save change feat.Save(); } IV.Sample animation and code: Download the demo animation: myHiMapVideo2.gif Download the sample code: myHiMapAdvanced.zip |
![]() |
| Tags |
| edit, electronic, enjoy, gis, himap, k-work, map, mobile, mobile gis, phone |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
| |
| ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| using C# to create a GIS program of mobile phone | dyh | Other Mapping Platforms | 0 | 11-02-2008 09:13 PM |
| Tracking your GPS-enabled Mobile Phone | Johannes Kebeck's Blog | Virtual Earth Blogs | 0 | 03-26-2008 04:00 PM |
| Help me choose my next mobile phone | VE Team | Virtual Earth Blogs | 0 | 12-18-2007 09:01 PM |
| Innovative scenarios for mobile learning at the Seriously Mobile Workshop | Eric Frost | Press Releases | 0 | 05-08-2007 07:30 PM |
| Sprint Launches First Phone With Windows Mobile 5.0 Platform | Eric Frost | News and Announcements | 0 | 09-18-2005 10:41 AM |