3

I am using ESRI silverlight. I have graphic objects on the screen and each graphic object has an attached silverlight label. What I want to do is to have each label shown at a fixed screen (pixel) distance from graphic object. This seems not possible as esri draws the labels according to the envelope given in map coordinates.

Is there an easy way to show labels at fixed screen coordinates, not in map coordinates?

1

This post at Sharp GIS blog shows how to work with custom cursors, perhaps this would apply to your use case too.

1

You can add the labels manually using TextBlocks to the same panel as the map. You might need to set the Canvas.Top, Canvas.Left, and Canvas.ZIndex. Remember all panels inherit from Canvas. Just iterate over each of the graphics in your collection and use the MapToScreen method on the map object to convert a vertice's MapPoint into a screen coordinate.

You can find more information on the Map.MapToScreen method on the esri silverlight api page.

Look under ESRI.ArcGIS.Client Assembly -> ESRI.ArcGIS.Client -> Classes -> Map -> Methods -> MapToScreen

You can read about how to use the canvas control on the MSDN page.

0

you could always create another graphic and manually set the label text. In the javascript api you can use a graphic TextSymbol. I'll check the silverlight API and see if it has the same

http://help.arcgis.com/EN/webapi/javascript/arcgis/help/jsapi/textsymbol.htm

There is http://help.arcgis.com/en/webapi/silverlight/apiref/ESRI.ArcGIS.Client~ESRI.ArcGIS.Client.Symbols.TextSymbol_members.html in the silverlight api which could help you out. It's super easy with points as you already have the spot where you want to put the label anchor. If it's lines/polygons you can use the geometry service's label points method to get the label location.

http://resources.esri.com/help/9.3/arcgisserver/apis/javascript/arcgis/help/jsapi_start.htm#jsapi/GeometryService.htm#labelpoints

Here's another javascript example but you get the point.

http://resources.esri.com/help/9.3/arcgisserver/apis/javascript/arcgis/help/jssamples_start.htm#jssamples/util_label_point.html

  • Thanks for the response, but the problem is that, textsymbol does not have a background color property. In fact I have the same problem while using other symbols than marker symbols. when user focuses to map, their size changes. – daryal Apr 28 '11 at 13:04
  • @daryal this doesn't sound related to the question that was asked. – Steve May 3 '11 at 15:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.