ThinkGeo.com    |     Documentation    |     Premium Support

Visualizing data with coloring the location according to weight of data

How can I show  stats in form of different colors depending on weight of
stat,the screenshot#1 have only one color in select area I want to show
different colors just like in screenshot 2"

screenshot#1



screenshot#2



Have you looked into using a ClassBreakStyle? Basically, you create it with the column you want to use to weight, and then add ClassBreaks with the value and the AreaStyle to use.



giseditorwiki.thinkgeo.com/giseditorwiki/class_break_style



Jay

Thanks Jay Class break style use data of shape file store in dbf files but I want to visualize data of  a database.

Hi Shehraz,


Please see the samples at "wiki.thinkgeo.com/wiki/map_suite_mvc_edition_all_samples#heat_map" or "wiki.thinkgeo.com/wiki/map_suite_services_edition_styles_samples#valuestyle_with_countries"





Any questions please let me know.



Thanks,
Peter

Thanks Peter,






The links you have provided are using ShapeFileFeatureSource for visualization  but I want to use data from a SQL Database not from a Shapefile. 

Hi Shehraz, 
  
 Please use the SqliteFeatureSource which has been built-in "SQLiteExtension.dll" instead. The latest DLLs can be gotten from product center. 
  
 Thanks, 
 Peter

Hi Peter, 



Please guide me if I want to use a JSON or an array list data for visualization.

Hi Shehraz,



Sorry that I was confused with the previous reply. The class “MsSql2008FeatureLayer” can be used to load data from a SQL database. More information please see here.



The attached is the sample which shows how to load data from a SQL database and to display areas in different colors and to display the feature information when mouse click.




More samples about MVC edition
please see here.






Thanks,
Peter




GetFeatureById.zip (812 KB)

Hi Peter, problem statement is that,I provide a drop down to user he will select some location and I have to show some data on selected location. 
 I am getting data from a database about selected feature and it is a multi value attribute data for example literacy ration.Data is in form for JSON and I want to visualize it on map at same location that user has selected. 
 Please guide me how can I achieve this.I have spend alot of time on it but there is no desirable output.

Hi Shehraz,


 


The attached is a sample that uses the popup to display the
data of feature when user selected.


 


Please click here to see more samples about the MVC edition.


 


Thanks,


Peter



PopupSmaple_Mvc.zip (812 KB)

Hi Peter,

 I have an issue, Popup is not showing on map,and the reason I think is that, popup array is empty in client side although I have initialized it while creating map in server side.

Controller code:



        Map Map1 = null;

        public ActionResult Index3()

        {

            Map1 = new Map(“map”,

         new System.Web.UI.WebControls.Unit(100, System.Web.UI.WebControls.UnitType.Percentage), 510);

          





            Map1.MapTools.LoadingImage.ImageUri = new Uri(Server.MapPath(@"~/ShapeFiles/loading_logofinal_by_zegerdon-d60eb1v.gif"));

            Map1.MapTools.LoadingImage.Enabled = true;

            Map1.MapTools.LoadingImage.Height = 64;

            Map1.MapTools.LoadingImage.Width = 64;

            Map1.MapTools.ScaleLine.Enabled = true;

            Map1.MapUnit = GeographyUnit.DecimalDegree;

            Map1.MapTools.MouseCoordinate.MouseCoordinateType = MouseCoordinateType.LongitudeLatitude;

            Map1.MapTools.MouseCoordinate.Enabled = true;

            Map1.Cursor = CursorType.Pointer;

            //Map1.MapBackground.BackgroundBrush = new GeoSolidBrush(GeoColor.GeographicColors.Swamp);





            ShapeFileFeatureLayer PakLayer = new ShapeFileFeatureLayer(Server.MapPath(@"~/ShapeFiles/PAK_adm0.shp"));

            PakLayer.ZoomLevelSet.ZoomLevel04.DefaultAreaStyle = AreaStyles.Country1;

            PakLayer.ZoomLevelSet.ZoomLevel04.DefaultTextStyle = TextStyles.CreateSimpleTextStyle(“NAME_ENGLI”, “Arial”, 8, DrawingFontStyles.Italic, GeoColor.StandardColors.Crimson, 3, 3);//TextStyles.Capital3(“NAME_1”);

            PakLayer.ZoomLevelSet.ZoomLevel04.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level05;

            ShapeFileFeatureLayer.BuildIndexFile(Server.MapPath(@"~/ShapeFiles/PAK_adm0.shp"));





            ShapeFileFeatureLayer capitalLayer = new ShapeFileFeatureLayer(Server.MapPath(@"~/ShapeFiles/PAK_adm1.shp"));

            capitalLayer.ZoomLevelSet.ZoomLevel06.DefaultAreaStyle = AreaStyles.CreateSimpleAreaStyle(GeoColor.SimpleColors.PaleGreen, GeoColor.FromArgb(100, GeoColor.SimpleColors.BrightOrange));

            capitalLayer.ZoomLevelSet.ZoomLevel06.DefaultTextStyle = TextStyles.CreateSimpleTextStyle(“NAME_1”, “Arial”, 8, DrawingFontStyles.Italic, GeoColor.StandardColors.Green, 3, 3);//TextStyles.Capital3(“NAME_1”);

            capitalLayer.ZoomLevelSet.ZoomLevel06.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level06;



            ShapeFileFeatureLayer DivisionLayer = new ShapeFileFeatureLayer(Server.MapPath(@"~/ShapeFiles/PAK_adm2.shp"));

            DivisionLayer.ZoomLevelSet.ZoomLevel07.DefaultTextStyle = TextStyles.CreateSimpleTextStyle(“Name_2”, “Arial”, 8, DrawingFontStyles.Italic, GeoColor.StandardColors.Chocolate, 3, 3);

            DivisionLayer.ZoomLevelSet.ZoomLevel07.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level08;

            DivisionLayer.ZoomLevelSet.ZoomLevel07.DefaultAreaStyle = AreaStyles.CreateSimpleAreaStyle(GeoColor.SimpleColors.PaleOrange, GeoColor.FromArgb(100, GeoColor.SimpleColors.BrightGreen));





            ShapeFileFeatureLayer districtLayer = new ShapeFileFeatureLayer(Server.MapPath(@"~/ShapeFiles/PAK_adm3.shp"));

            //districtLayer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle = TextStyles.Capital3(“NAME_3”);

            districtLayer.ZoomLevelSet.ZoomLevel08.DefaultTextStyle = TextStyles.CreateSimpleTextStyle(“NAME_3”, “Arial”, 8, DrawingFontStyles.Italic, GeoColor.StandardColors.Black, 3, 3);

            districtLayer.ZoomLevelSet.ZoomLevel08.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level09;

            districtLayer.ZoomLevelSet.ZoomLevel08.DefaultAreaStyle = AreaStyles.CreateSimpleAreaStyle(GeoColor.SimpleColors.PastelYellow, GeoColor.FromArgb(100, GeoColor.SimpleColors.DarkGreen));



            districtLayer.DrawingMarginPercentage = 50;

            ShapeFileFeatureLayer tahseelLayer = new ShapeFileFeatureLayer(Server.MapPath(@"~/ShapeFiles/PAK_Tehsil_Boundary.shp"));

            //tahseelLayer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle = TextStyles.Capital3(“NAME_3”);

            tahseelLayer.ZoomLevelSet.ZoomLevel10.CustomStyles.Add(TextStyles.CreateSimpleTextStyle(“TEHSIL”, “Arial”, 8, DrawingFontStyles.Italic, GeoColor.StandardColors.Black, 3, 3));

            tahseelLayer.ZoomLevelSet.ZoomLevel10.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

            tahseelLayer.ZoomLevelSet.ZoomLevel10.CustomStyles.Add(AreaStyles.CreateSimpleAreaStyle(GeoColor.SimpleColors.White, GeoColor.FromArgb(100, GeoColor.SimpleColors.Black)));

            ShapeFileFeatureLayer.BuildIndexFile(Server.MapPath(@"~/ShapeFiles/PAK_Tehsil_Boundary.shp"));

            LayerOverlay staticOverlay = new LayerOverlay(“StaticOverlay”);

            staticOverlay.IsBaseOverlay = false;

            staticOverlay.Layers.Add(“PakLayer”, PakLayer);

            staticOverlay.Layers.Add(“CapitalLayer”, capitalLayer);

            staticOverlay.Layers.Add(“DivisionLayer”, DivisionLayer);

            staticOverlay.Layers.Add(“DistrictLayer”, districtLayer);

            staticOverlay.Layers.Add(“TahseelLayer”, tahseelLayer);





            districtLayer.Open();

            Map1.CurrentExtent = districtLayer.GetBoundingBox();

            Map1.CustomOverlays.Add(staticOverlay);







            InMemoryFeatureLayer highlightLayer = new InMemoryFeatureLayer();

            highlightLayer.ZoomLevelSet.ZoomLevel10.DefaultAreaStyle = AreaStyles.CreateSimpleAreaStyle(GeoColor.FromArgb(165, 42, 42, 100), GeoColor.GeographicColors.DeepOcean);

            highlightLayer.ZoomLevelSet.ZoomLevel10.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

            InMemoryFeatureLayer highlightLayer2 = new InMemoryFeatureLayer();

            highlightLayer2.ZoomLevelSet.ZoomLevel07.DefaultAreaStyle = AreaStyles.CreateSimpleAreaStyle(GeoColor.FromArgb(140, 50, 30, 120), GeoColor.GeographicColors.Dirt);

            highlightLayer2.ZoomLevelSet.ZoomLevel07.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level07;

            InMemoryFeatureLayer highlightLayer3 = new InMemoryFeatureLayer();

            highlightLayer3.ZoomLevelSet.ZoomLevel08.DefaultAreaStyle = AreaStyles.CreateSimpleAreaStyle(GeoColor.FromArgb(160, 86, 120, 160), GeoColor.GeographicColors.Dirt);

            highlightLayer3.ZoomLevelSet.ZoomLevel08.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level09;

            LayerOverlay dynamicOverlay = new LayerOverlay(“HightLightDynamicOverlay”);

            dynamicOverlay.Layers.Add(“HighLightLayer”, highlightLayer);

            dynamicOverlay.Layers.Add(“HighLightLayer2”, highlightLayer2);

            dynamicOverlay.Layers.Add(“HighLightLayer3”, highlightLayer3);

            dynamicOverlay.IsBaseOverlay = false;

            Map1.CustomOverlays.Add(dynamicOverlay);

            Map1.Popups.Add(new CloudPopup(“information”) { AutoSize = true, IsVisible = false });



            ViewBag.map = Map1;

            Session[“map”] = Map1;

            return View();

        }



Client Side code screenshot showing that there is no Popup defined but that’s not true.



Hi Shehraz, 



Please pass the position argument to Popup when create a new CloudPopup instance, because only the popup is contained in current extent will be rendered to client.  Maybe the code just like the following: 


map.Popups.Add(new CloudPopup("information", map.CurrentExtent.GetCenterPoint()) { AutoSize = true, IsVisible = false });



 Thanks, 

Peter

Thanks Peter You resolve my issue.

Hi Peter I Have another question.I have multiple layers on map and I want to get layer index where I clicked , It will be better if I get the name of layer where user clicked. If there is any way to do that please help me.

Hi Shehraz, 
  
 When user click on the map it will pass the position to the server and according to the position we can get the layers which are clicked and then return the data to client. 
  
 To find the layers are clicked: 
 private IEnumerable<Layer> GetLayers(Map map, PointShape position)
        {
            foreach (var layer in map.DynamicOverlay.Layers.OfType<FeatureLayer>())
            {
                layer.Open();
                var features = layer.QueryTools.GetFeaturesContaining(position, ReturningColumnsType.NoColumns);
                if (features.Count > 0)
                {
                    yield return layer;
                }
                layer.Close();
            }

            yield break;
        }
 
  
  
 Please let me know if you have any questions. 
  
 Thanks, 
 Peter