ThinkGeo.com    |     Documentation    |     Premium Support

Display Label at particular position

Hello,


I need to display Lable at a given latitude and longitude position with an icon. I refer sample examples but some examples are used .shp file. I dont know what is the use of Shape file and how can we make that file?


Thanks,


Krunal



If you need to display a label with an icon at a specific position in Longitude and Latitude, you can use an InMemoryFeatureLayer for that with the appropriate styles set up. Look at the code below, it will place an icon and a label on top of the World Map Kit:


 



           winformsMap1.MapUnit = GeographyUnit.DecimalDegree;
            winformsMap1.CurrentExtent = new RectangleShape(-125, 47, -67, 25);
            winformsMap1.BackgroundOverlay.BackgroundBrush = new GeoSolidBrush(GeoColor.FromArgb(255, 198, 255, 255));

            //Displays the World Map Kit as a background.
            ThinkGeo.MapSuite.DesktopEdition.WorldMapKitWmsDesktopOverlay worldMapKitDesktopOverlay = new ThinkGeo.MapSuite.DesktopEdition.WorldMapKitWmsDesktopOverlay();
            winformsMap1.Overlays.Add(worldMapKitDesktopOverlay);

            InMemoryFeatureLayer pointLayer = new InMemoryFeatureLayer();

            double Longitude = -95.2809;
            double Latitude = 38.9543;
            Feature myFeature = new Feature(new PointShape(Longitude, Latitude));
            myFeature.ColumnValues.Add("Text", "My Feature");

            pointLayer.Open();
            pointLayer.Columns.Add(new FeatureSourceColumn("Text"));
            pointLayer.EditTools.BeginTransaction();
            pointLayer.EditTools.Add(myFeature);
            pointLayer.EditTools.CommitTransaction();
            pointLayer.Close();

            PointStyle myPointStyle = new PointStyle(new GeoImage(@"..\..\Data\myicon.gif"));
            myPointStyle.PointType = PointType.Bitmap;
            pointLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle = myPointStyle;
            pointLayer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle = TextStyles.CreateSimpleTextStyle("Text", "Arial", 12, DrawingFontStyles.Bold,
                                                                        GeoColor.StandardColors.Black, GeoColor.StandardColors.White, 3, -10, 10);
            pointLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;


            LayerOverlay layerOverlay = new LayerOverlay();
            layerOverlay.Layers.Add(pointLayer);
            winformsMap1.Overlays.Add(layerOverlay);


            winformsMap1.Refresh();



I have to apologize that the code I send you last is for the Desktop edition. But the part for setting the InMemoryFeatureLayer is identical with the Web edition. I also recommend you check out the Code Community project, GPS to Google Map that shows almost the exact thing you are asking. Note that in addition, we are doing some projection to go from Geodetic to the Google Map projection.


code.thinkgeo.com/projects/show/gpstogooglemap