ThinkGeo.com    |     Documentation    |     Premium Support

Issues with Markers with Text

I am currently working with markers and text. I have noticed a few strange things going on.

First, when I add text with a text offset, it changes the location of the markers.

The second thing is all my markers are clickable. So when I add text, the boundary for where you can click for the marker expands significantly to the point where almost half my map is clickable (something I would prefer not to have happen). I have checked that my image does not have any extra pixels around it.

Thanks!
Josh

Hi Josh,

Please check the answers below:

I checked the source code and found the ImageOffsetX/ImageOffsetY can impact the position of the marker, the following figure shows the result on my side.

In the figure, there are 2 markers with the same coordinates, one has the text with offset and the other doesn’t. The code like below:

var marker1 = new Marker(-8922952.93266, 2984101.58384, new WebImage("~/Content/images/marker_blue.gif", 21, 25) {Text = "Text", TextOffsetX = 10});
var marker2 = new Marker(-8922952.93266, 2984101.58384);
markerOverlay.Markers.Add(marker1);
markerOverlay.Markers.Add(marker2);

In MVC Edition the markers with text are drawn into a new image with the text like following, so please try reduce the text or the values of the TextOffestX/TextOffsetY to avoid the issue:

Hope it’s helpful.

Thanks,
Peter

Hi Peter,

Thanks for your quick response.

In regards to the second issue, unfortunately, I am not able to reduce the amount of text (I do not have more than four words on each marker) or the TextOffset due to restraints by my client. The reason for not wanting to adjust the TextOffset is it causes the text to not be readable. Would it be better for me to instead of using the text available with markers, overlay text either using another marker overlay or just a different type of overlay?

Thanks!
Josh

Hi Josh,

I guess it’s the an option for this. Maybe we can try the following steps:

  1. Add the marker without text.
  2. Create a new layer which contains the lon/lat of the markers and apply the TextStyle to the layer.

Any questions please let us know.

Thanks,
Peter

Hi Peter,

I have tried what you have said. I am not able to get a normal text layer to appear in front of a marker. I did mess around with putting the text in a blank marker layer, but the issue I am running into with that is, the user can no longer select in the location where the text is. Any suggestions would be greatly appreciated.

Thanks!
Josh

Hi Josh,

Here is a solution for you. Attached is a sample shows that, please check it out.
Mvc_PointStyleTextStyleAndClickMarkerSample.zip (106.4 KB)

Frist of all, please create an image which is consistent with your marker icon but full transparency.
Then we can try the following steps:

  1. Added a marker with full transparency image.

  2. Create a layer with PointStyle and TextStyle to display image and text at the same coordinate.

  3. Adjust marker’s offiset and PointStyle’s offiset, make the transparency marker coincide with the image on the layer.

In this solution, you can reduce the valid range of the click event by reduce the size of the transparency image.

Hope it’s helpful.

Thanks,
Emil