ThinkGeo.com    |     Documentation    |     Premium Support

Transparant label

Is there any to add a user-defined transparent, description label to a drawed shape. In previous webedition (2.55 version), I can add description by using the AreaMapShape Name property. Here's the scenarious, user draw a rectangle/square shape, user then click on the shape which prompt them to enter the description value. 


For version 3.1, I have tried contextmenu and popup (both client and server side) without success.  Please advise 



Mark, 
  
   I can’t help you on the popup parts, Ben will have to cover that, but I can on drawing the label.  After you draw the track shape you can remove it from the EditOverlay and then add it to an InMemoryFeatureLayer.  Are you familiar with this?  Once inside of here you can add a new column to it called something like Name, I think you need to specify the columns when you create the InMemoryFeatureLayer…  Then you go to each feature and add a new dictionary item into the Feature.ColumnValues with a key of Name and a value of what they name you want is.  After you do that you can use a TextStyle on the zoom levels to draw the label however you want.  Make sure specify the column name as Name.   
  
   I’m not sure your expertise level with the new 3.x stuff but if you need me to I can put together a sample for you.  I am a bit behind in the posts so I would be able to send the demo until this weekend.  There has been allot of activity since our three releases and my cohort is out this week. 
  
 David

Mark, 
  
   I forgot about the transparent part.  For this just specify a GeoColor with an alpha value.  It will draw transparently based on this value. 
  
 David

Dave,  
 Thank you for your quick response. It would be great if you provide an example. Right now I am doing all the drawing on client-side, whichever events requiring postback, I add all the shapes from editoverlay into InMemoryFeatureLayer. I just can’t seems to incorporate the ColumnName. Please advise. Thanks

Mark, 
  
 Maybe you can try the Map.OnClientDrawEnd property. This property holds the javascripts that are executed each time you finish drawing a shape. You can write a javascript function that pops up a window and gathers the description values from user, then assign to this property. For example: 
  
 string drawEndScript = "function(feature){ 
        //pops up window and gather description values 
        … 
  
      //set the description values to the feature that was just drawn.  The feature object is passed to you by the parameter. 
      feature.name = descriptionName; 
 }"; 
  
 Map1.OnClientDrawEnd  = drawEndScript; 
  
  
 After postback, the description values that you added to the feature will enter into the ColumnValues collection of the feature in the EditOverlay.  
  
 Ray

Thanks Ray, It doesn’t seems to work.  
 On load, I set  
     Map1.OnClientDrawEnd = drawEndScript; 
 On Javascript,   
     var drawEndScript = function(feature) { 
           //alert('Enter Feature: ’ ); 
           feature.name = 'test label;  
      }  
  
 It doesn’t seems to do anything. I don’t see any javascript error.  
  
  


Mark, 
  
 Please try the function name. 
  
 On Javascript, 
 function drawEndHandler(feature){ 
       feature.name = "test label"; 
 } 
  
 On Page_Load, 
 Map1.OnClientDrawEnd = "drawEndHandler";

I tried that as well, doesn’t seems to work. I have tried adding description label on client-side & server-side, nothing seems to work. I am able to add description via ContextMenu or Popup. H owever, when the description text is long, ContextMenu/Popup layer cover the map.

David,


Any recommendation on how to create transparent label for user's drawn shape?



Mark,


Here attached is a solution for this problem, let me know for any queries.


Thanks,


Ben



335-Post5186.zip (97.1 KB)