Jump to content

UniMap - how to add marker on map creation


Mindaugas

Recommended Posts

Hello,

I am creating a UniMap at runtime and trying to add a marker to it, but UniForm is not loading.

procedure CreateMap(upanel: TUniPanel; lat, longt: Double);
var
  umap: TUniMap;
begin
  umap := TUniMap.Create(upanel);
  umap.Parent := upanel;
  umap.Align := alTop;
  umap.Height := 250;
  umap.LayoutConfig.Margin := '10 10 10 10';
  with umap.MapLayers.Add do
  begin
    LayerType := mlGoogle;
    MapType := mtRoadMap;
  end;
  umap.DefaultLat := lat;
  umap.DefaultLong := longt;
  umap.DefaultZoom := 15;
  with umap.Markers.Add do
  begin
    id:= 1;
    Latitude:= lat;
    Longitude:= longt;
    Icon.iconUrl := 'images/icons/marker-icon.png';
    Draggable:= True;
    AddToMap;
    PanToMarker(15);
  end;
end;

If I am not adding marker, uniform, and unimap load properly. 

I want that marker is shown on the unimap straight after creation (not after some event, like onclick, etc.). Is this possible? How to achieve this?

Thank You.

Link to comment
Share on other sites

  • 1 year later...
17 minutes ago, VolkovVitalD said:

Hello. Is there any result on this problem?

 Hello

Please use below solution for now. I'll add OnMapReady Event

procedure TMainForm.UniMap1AjaxEvent(Sender: TComponent; EventName: string;
  Params: TUniStrings);
begin
  if EventName='afterupdatehtml' then
    AddMarker
end;

 

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...