ThinkGeo.com    |     Documentation    |     Premium Support

Problem in placing customized text at start, stop and end points in mapsuiteRouting

 I am using mapsuite routing add-on with mapsuite desktop edition in order to get shortest path between two points over the street.

But i have been facing some problems. These problems are-


 


·         Can I place my own customized text at  start, end and stop points?


·         Can I show the details of start, end and stop points as soon as I hover mouse at these points?


·         Can I place my own customized bitmap at stop points instead of 1 and 2?


·         Can I show more than one  different paths simultaneously from source to destination in different colors?


 


Kindly help me out over these issues?


 


Thanks and Regards,


Manoj Kumar




 


Manoj,
 
Welcome to Map Suite discussion forum. From your description, do you want to get a custom routing result like below?
 

 
 
It’s simple to get it with RoutingLayer class, which allow us to define the StartPointStyle, EndPointStyle and stop points style, all of them are PointStyle that can be customize bitmap or something else. We also can display the different paths in different colors using ClassBreakStyle based on distance or ValueStyle based on some custom values. Please refer to the installation DesktopEdition samples in “Style” folder.
 
Here is a link gis.thinkgeo.com/Support/Dis...fault.aspx  about how to add MouseToolTop to an image when we hover mouse at these points.
 
Any questions please let us know. Thanks.
 
Johnny
 
 

Hi johnny 
  
  Many thanks for your reply.  
 The figure you shown is exactly what i want. I used PointStyle of StartPointStyle and i can load my own bitmap now. But i am not able to put my text over this start, end or stop point. And also, i want my custom bitmap along with my custom message. 
  
 Thanks and Regards, 
 Manoj Kumar 
  


There is a project, Routing Styles, in the Code Community, please check it out. I think it should give you a better idea on how to proceed.


code.thinkgeo.com/projects/show/routingstyles



Hi val,  
          Thanks a lot for your reply.  
 The link you provided actually helped a lot. But when i try to implement this code in my application it shows custom marks but it doesnt show custom labels. Here is the code- 
  
  
   InitializeComponent(); 
  
             winformsMap1.MapUnit = GeographyUnit.DecimalDegree; 
             winformsMap1.CurrentExtent = new RectangleShape(-97.7970203443604, 30.3231958204346, -97.6787456556397, 30.2358201795654); 
             ShapeFileFeatureLayer austinStreetsLayer = new ShapeFileFeatureLayer(@"C:\Program Files\ThinkGeo\Map Suite Routing Evaluation Edition 3.0\HowDoISamples\SampleData\Austinstreets.shp"); 
             austinStreetsLayer.ZoomLevelSet.ZoomLevel01.DefaultLineStyle = LineStyles.LocalRoad4; 
             austinStreetsLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20; 
             LayerOverlay austinStreetOverlay = new LayerOverlay(); 
             austinStreetOverlay.Layers.Add("austinStreetsLayer", austinStreetsLayer); 
             winformsMap1.Overlays.Add("austinStreetOverlay", austinStreetOverlay); 
             mapEngine.StaticLayers.Add("AustinStreets", austinStreetsLayer); 
             // Define a Routing layer to render the path and stops 
  
             austinStreetsLayer.Open(); 
             Feature feature_start = austinStreetsLayer.FeatureSource.GetFeatureById("4716", ReturningColumnsType.NoColumns); 
             Feature feature_stop1 = austinStreetsLayer.FeatureSource.GetFeatureById("5137", ReturningColumnsType.NoColumns); 
             Feature feature_stop2 = austinStreetsLayer.FeatureSource.GetFeatureById("8179", ReturningColumnsType.NoColumns); 
             Feature feature_end = austinStreetsLayer.FeatureSource.GetFeatureById("9638", ReturningColumnsType.NoColumns); 
             austinStreetsLayer.Close(); 
  
             InMemoryFeatureLayer pointsInMemoryFeatureLayer = new InMemoryFeatureLayer(); 
             //Adds column to InMemoryFeatureLayer for Type. 
             pointsInMemoryFeatureLayer.Open(); 
             pointsInMemoryFeatureLayer.Columns.Add(new FeatureSourceColumn("Type")); 
             pointsInMemoryFeatureLayer.Close(); 
             ValueStyle valuestyle1 = new ValueStyle(); 
             valuestyle1.ColumnName = "Type"; 
             valuestyle1.ValueItems.Add(new ValueItem("Start", new PointStyle(PointSymbolType.Triangle, new GeoSolidBrush(GeoColor.StandardColors.Green), 8))); 
             valuestyle1.ValueItems.Add(new ValueItem("Stop1", new PointStyle(PointSymbolType.Star, new GeoSolidBrush(GeoColor.StandardColors.Yellow), 8))); 
             valuestyle1.ValueItems.Add(new ValueItem("Stop2", new PointStyle(PointSymbolType.Star, new GeoSolidBrush(GeoColor.StandardColors.Yellow), 8))); 
             valuestyle1.ValueItems.Add(new ValueItem("End", new PointStyle(PointSymbolType.Triangle, new GeoSolidBrush(GeoColor.StandardColors.Red), 8))); 
             pointsInMemoryFeatureLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(valuestyle1); 
             pointsInMemoryFeatureLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20; 
             Feature StartFeature = new Feature(feature_start.GetShape().GetCenterPoint()); 
             StartFeature.ColumnValues["Type"] = "Start"; 
            Feature StopFeature1 = new Feature(feature_stop1.GetShape().GetCenterPoint()); 
             StopFeature1.ColumnValues["Type"] = "Stop1"; 
             Feature StopFeature2 = new Feature(feature_stop2.GetShape().GetCenterPoint()); 
            StopFeature2.ColumnValues["Type"] = "Stop2"; 
             Feature EndFeature = new Feature(feature_end.GetShape().GetCenterPoint()); 
             EndFeature.ColumnValues["Type"] = "End"; 
  
             pointsInMemoryFeatureLayer.InternalFeatures.Add(StartFeature); 
             pointsInMemoryFeatureLayer.InternalFeatures.Add(StopFeature1); 
             pointsInMemoryFeatureLayer.InternalFeatures.Add(StopFeature2); 
             pointsInMemoryFeatureLayer.InternalFeatures.Add(EndFeature); 
  
             LayerOverlay ptoverlay = new LayerOverlay(); 
             ptoverlay.Layers.Add("PointLayer", pointsInMemoryFeatureLayer); 
             winformsMap1.Overlays.Add("PointOverlay", ptoverlay); 
  
             winformsMap1.Refresh(); 
           
 This code shows green , yellow and red marks at start stop and end points. But i could not find the labels like start, stop1, stop2, End. Please help me out… 
  
  


It is a little bit difficult to look at a bulk of code outside its context, without being able to run it and see what is happening. But by looking at your code, I could not find where you set up the Style to have the labels showing. You will notice that in the project “Routing Styles”, there is the line: 
  
  pointsInMemoryFeatureLayer.ZoomLevelSet.ZoomLevel16.CustomStyles.Add(TextStyles.CreateSimpleTextStyle(“Type”, “Arial”, 12, DrawingFontStyles.Bold, GeoColor.StandardColors.Black,GeoColor.StandardColors.White,3, 11, 0)); 
  
 It tells the Layer to draw labels. I don’t see anything like that.  
  
 I hope this is going to help. If this is still not helping. Please, send us a little sample app and we will correct the code. Thank you.

Thanks a lot Val… this just worked… Thanks a lot for your help and support. You guys are just wonderful…

That’s our pleasure, :-) Manoj.

Hi val, 
             There is one more problem. Can you tell me how can i show two different paths at the same time in different colors? 
 For exmample From A to B there is one route say X and another route say Y. 
 I need to show both of these routes in the map in different colors? How can i do it? 
  
 Thanks 
 Manoj

Manoj, 
  
 Add the 2 paths to 2 inMemoryFeatureLayer, set the ZoomLevel for both of them to make them have different color, and then you can get it.  
  
 Ben

Hello Ben,  
                   I am sorry for not explaining my problem clearly. Actually i am asking how to get alternative routes between two points. I want to show both routes (original and alternative) on the map in different colors. The solution you told me works when we have all the co-ordinates in between source and destination for original routes and alternative routes. 
  
 Thanks 
 Manoj

I want to make sure exactely what you are asking for. You want to show on the map the different routes based on different algorithms from a start and en end point. Correct?

Sorry val for late reply… Actually what i want is all the possible paths from source to destination at the same time. What you are telling me is may be shortest path from soruce to destination using different algorithms.

There is one more problem Yale… I downloaded spain map from ESRI website. This map contains .shp, .shx, .dbf and .prj files. When i specify the path of shp file application throws an exception saying shp file does not have corresponding idx (index file). If i set RequireIndex property of ShapeFileFeatureLayer class it just shows nothing. 
  
 In short can you tell me how can i use shp files of companies other than you. I am posting sample code… please have a look… 
  
  private void btn_loadanother_Click(object sender, EventArgs e) 
         { 
             winformsMap1.MapUnit = GeographyUnit.DecimalDegree; 
             winformsMap1.CurrentExtent = new RectangleShape(-97.745827547760484, 30.297694742808115, -97.728208518132988, 30.285123327073894); 
             winformsMap1.BackgroundOverlay.BackgroundBrush = new GeoSolidBrush(GeoColor.FromArgb(255, 233, 232, 214)); 
             ShapeFileFeatureLayer roadlayer = new ShapeFileFeatureLayer(@"C:\Documents and Settings\Manoj\Desktop\sample_italy_slovenia_shape (1)\sample_italy-slovenia_shape_gfk_geomarketing\maps\Italy cities over 100K.shp"); 
            // ShapeFileFeatureLayer roadlayer = new ShapeFileFeatureLayer(@"C:\Program Files\ThinkGeo\Map Suite Desktop Evaluation Edition 3.0\Samples\SampleData\Data\Countries02.shp"); 
             roadlayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.Country2; 
             roadlayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20; 
           //  roadlayer.RequireIndex = false; 
              LayerOverlay shortestLineOverlay = new LayerOverlay(); 
             shortestLineOverlay.Layers.Add("ShortestLineLayer", roadlayer); 
             winformsMap1.Overlays.Add("ShortestLineOverlay", shortestLineOverlay); 
              // winformsMap1.CurrentExtent = new RectangleShape(-139.2, 92.4, 120.9, -93.2); 
             winformsMap1.Refresh(); 
  
         }

if I create index file using Mapsuite explorer or using BuildIndexFile funciton it creates a corresponding index file. But map does not show anything… Please help on this issue…

In our experience when a problem as you describe occurs, it is often because the projection of the shapefile is different from Geodetic (decimal degrees). Can you send us the strings you have in the prj files? This is the first thing I would check. Thank you.

Hi Val, 
                 Thanks for your reply… Actually i am a beginner in GIS application development. I am sorry for embarassing you for asking basic questions. But before purchasing the software we need to know the capabilites of software. Well, i am sending you the string.  
  
 GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]] 
  
 Many thanks val for your co-operation.

Manoj, 
  
 Sorry for the delay. 
  
 I think according to the projection string, the map unit should be set to DecimalDegree as you have done. So, if you are sure you are setting the correct Style for your data, then I have to doubt there is some special on your data. If possible, could you send us your data? 
  
 Any more questions just feel free to let me know. 
  
 Thanks. 
  
 Yale