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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...