Label near marker


Is it possible to put a label to every marker, or a field with text?
Sincerely Peter


I found  a sample below, but I would need a complete compileable example.

var Marker: TMarker;
WebGMapsGeocoding1.Address := 'Paris, France';
if WebGMapsGeocoding1.LaunchGeocoding = erOk then begin Marker := WebGMaps1.Markers.Add; Marker.Latitude := WebGMapsGeocoding1.ResultLatitude;

Marker.Longitude := WebGMapsGeocoding1.ResultLongitude; Marker.Title := 'Destination: ' + WebGMapsGeocoding1.Address; Marker.MapLabel.Text := '<b>Destination:</b> ' + WebGMapsGeocoding1.Address; Marker.MapLabel.Color := clYellow; Marker.MapLabel.BorderColor := clRed; Marker.MapLabel.Font.Color := clRed; Marker.MapLabel.Font.Size := 14; Marker.MapLabel.Font.Name := 'Tahoma'; WebGMaps1.CreateMapMarker(Marker); end;

Sincerely Peter


I am creating the markers in the following way:

Icon := LogRecordNumericArray[n].Icon;
        If(FIO.Exists(icon)) then
          WebGMaps1.Markers.Add(lat,lon, Title, icon, true, true, true, false, false, 0, icDefault, -1, -1, -1, -1, '');

How can this be put together with the source above?

Sincerely Peter

You can find a full example of how to add a label to a marker in the TWebGMaps DirectionsDemo.

This is the relevant code from the demo:

  Marker: TMarker;
  Marker := WebGMaps1.Markers.Add;
  Marker.Latitude := Route.Legs[0].StartLocation.Latitude;
  Marker.Longitude := Route.Legs[0].StartLocation.Longitude;
  Marker.Title := 'Start Location';
  Marker.MapLabel.Text := 'Start Location: ' + Route.Legs[0].StartAddress;


Thank you for the example. Now I have added the labels to every marker.

Sincerely Peter

I can't see the way that this might get done with WebOSMaps markers. Is it possible?


Unfortunately marker labels are currently not supported in TWebOSMaps. This is a limitation of the version of the OpenLayers API which TWebOSMaps is based on.

Alternatively you can try using TMS VCL WebGMaps or TMS FNC Maps instead.


Is it possible to have the label moveable?

Sincerely Peter

Unfortunately moveable labels are currenlty not supported.
We would have to investigate if this is supported in the API and if it can be implemented in a future version.

Is it possible to use the Marker without an icon, so that only the MapLabel is used?


A marker always has an icon or a custom image.
You could use an empty image as a workaround here.