{"action":"opened","issue":{"url":"https://api.github.com/repos/DotSpatial/DotSpatial/issues/665","repository_url":"https://api.github.com/repos/DotSpatial/DotSpatial","labels_url":"https://api.github.com/repos/DotSpatial/DotSpatial/issues/665/labels{/name}","comments_url":"https://api.github.com/repos/DotSpatial/DotSpatial/issues/665/comments","events_url":"https://api.github.com/repos/DotSpatial/DotSpatial/issues/665/events","html_url":"https://github.com/DotSpatial/DotSpatial/issues/665","id":153417638,"number":665,"title":"Multiple point and images in one layer","user":{"login":"mogikanin","id":840681,"avatar_url":"https://avatars.githubusercontent.com/u/840681?v=3","gravatar_id":"","url":"https://api.github.com/users/mogikanin","html_url":"https://github.com/mogikanin","followers_url":"https://api.github.com/users/mogikanin/followers","following_url":"https://api.github.com/users/mogikanin/following{/other_user}","gists_url":"https://api.github.com/users/mogikanin/gists{/gist_id}","starred_url":"https://api.github.com/users/mogikanin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mogikanin/subscriptions","organizations_url":"https://api.github.com/users/mogikanin/orgs","repos_url":"https://api.github.com/users/mogikanin/repos","events_url":"https://api.github.com/users/mogikanin/events{/privacy}","received_events_url":"https://api.github.com/users/mogikanin/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/DotSpatial/DotSpatial/labels/CodePlex","name":"CodePlex","color":"ededed"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-05-06T09:50:53Z","updated_at":"2016-05-06T09:50:53Z","closed_at":null,"body":"**This issue was imported from [CodePlex](http://dotspatial.codeplex.com/workitem/25405)**\r\n\r\n**[Hactic](http://www.codeplex.com/site/users/view/Hactic)** wrote 2014-04-20 at 14:57\r\n<pre><code>        public void LoadMarkers()\n        {\n            try\n            {\n                //uxMap represents the DotSpatial.Control.Map instance\n\n                double[] dd1 = new double[] { 4.99, 52.673321 };\n                double[] dd2 = new double[] { 5.21, 52.912433 };\n                double[] dd3 = new double[] { 5.82, 53.581653 };\n\n                List<double[]> list = new List<double[]>();\n                list.Add(dd1);\n                list.Add(dd2);\n                list.Add(dd3);\n\n                //Do something similar with images\n                Image img1 = Image.FromFile(@\"C:\\file1.png\");\n                Image img2 = Image.FromFile(@\"C:\\file2.png\");\n                Image img3 = Image.FromFile(@\"C:\\file3.png\");\n\n                List<Image> listImg = new List<Image>();\n                listImg.Add(img1);\n                listImg.Add(img2);\n                listImg.Add(img3);\n\n                FeatureSet pointCoords = new FeatureSet(DotSpatial.Topology.FeatureType.Point);\n                pointCoords.Projection = uxMap.Projection;\n\n                DataColumn column1 = new DataColumn(\"ID\");\n                DataColumn column2 = new DataColumn(\"label\");\n\n                pointCoords.DataTable.Columns.Add(column1);\n                pointCoords.DataTable.Columns.Add(column2);\n\n                pointCoords.Projection = uxMap.Projection;\n\n                DotSpatial.Symbology.IFeatureLayer fl = uxMap.Layers.Add(pointCoords);\n                MapLabelLayer ll = new MapLabelLayer();\n\n                fl.LegendText = \"<My Layer Name>\";\n                fl.LabelLayer = ll;\n\n                ll.Symbolizer = new DotSpatial.Symbology.LabelSymbolizer\n                {\n                    FontFamily = \"Tahoma\",\n                    FontColor = Color.Black,\n                    FontSize = 8,\n                    BackColor = Color.White,\n                    BackColorEnabled = true,\n                    BackColorOpacity = 0.5f\n                };\n\n                int pointID = 1;\n\n                DotSpatial.Symbology.PointScheme pointScheme = new DotSpatial.Symbology.PointScheme();\n                pointScheme.ClearCategories();\n\n                foreach (var fe in list)\n                {\n                    double x = fe[0];\n                    double y = fe[1];\n\n                    // I use a custom class to set the coordinates of the points. \n                    // You may have to use your own depending on your projection.\n                    System.Windows.Point pLo = LatLonToMeters(y, x);\n\n                    DotSpatial.Topology.Coordinate c = new DotSpatial.Topology.Coordinate(pLo.X, pLo.Y);\n                    DotSpatial.Topology.Point point = new DotSpatial.Topology.Point(c);\n\n                    IFeature currentFeature = pointCoords.AddFeature(point);\n\n                    currentFeature.DataRow[\"ID\"] = pointID;\n                    currentFeature.DataRow[\"label\"] = \"point #\" + pointID.ToString();\n\n                    DotSpatial.Symbology.PictureSymbol pis = new DotSpatial.Symbology.PictureSymbol();\n                    DotSpatial.Symbology.PointCategory pc = new DotSpatial.Symbology.PointCategory(pis);\n\n                    foreach (IFeature f in pointCoords.Features)\n                    {\n                        if (f.Coordinates[0] == currentFeature.Coordinates[0])\n                        {\n                            //Here you can set any image you like. You can set one for each individual point.\n                            Image img = listImg[pointID - 1];\n\n                            DotSpatial.Symbology.Size2D sz = new DotSpatial.Symbology.Size2D(img.Width, img.Height);\n                            pis.Image = img;\n                            pis.Size = sz;\n\n                            pc.Symbolizer.ScaleMode = DotSpatial.Symbology.ScaleMode.Simple;\n                            pc.FilterExpression = \"[ID]='\" + currentFeature.DataRow[\"ID\"].ToString() + \"'\"; // <-- this is extremely important. Here the point ID is set\n                            pc.LegendText = currentFeature.DataRow[\"label\"].ToString();\n\n                            pointScheme.AddCategory(pc);\n\n                            ll.Symbology.Categories[0].Expression = \"[\" + fl.DataSet.DataTable.Columns[1].ColumnName + \"]\"; // <-- again, extremely important. Here the label value is set (Set to the point ID)\n                        }\n                    }\n\n                    pointID++; // bump up the ID's with one\n                }\n\n                fl.Symbology = pointScheme;\n                fl.ApplyScheme(pointScheme);\n                fl.ShowLabels = true; // <-- without this set, the labels won't show\n\n                //Some built in Invoking just in case you work from a different thread as I tend to do\n\n                if (InvokeRequired)\n                {\n                    Invoke(new System.Windows.Forms.MethodInvoker(delegate\n                    {\n                        uxMap.Invalidate();\n                        uxMap.Refresh();\n                    }));\n                }\n                else\n                {\n                    uxMap.Invalidate();\n                    uxMap.Refresh();\n                }\n            }\n            catch (Exception ex)\n            {\n                MessageBox.Show(ex.ToString());\n            }\n        }\n\n        private const int TileSize = 256;\n        private const int EarthRadius = 6378137;\n        private const double InitialResolution = 2 * Math.PI * EarthRadius / TileSize;\n        private const double OriginShift = 2 * Math.PI * EarthRadius / 2;\n\n        //Converts given lat/lon in WGS84 Datum to XY in Spherical Mercator EPSG:900913\n        public static System.Windows.Point LatLonToMeters(double lat, double lon)\n        {\n            var p = new Point();\n            p.X = lon * OriginShift / 180;\n            p.Y = Math.Log(Math.Tan((90 + lat) * Math.PI / 360)) / (Math.PI / 180);\n            p.Y = p.Y * OriginShift / 180;\n            return p;\n        }</code></pre>"}}