2
votes

Please can anyone explain me how to Change the Marker Icon in Delphi for a android App?

My try don't work

s.Create(16, 16); //Image size
position.Latitude := mapview1.Location.Latitude;
position.Longitude := mapview1.Location.Longitude;
MyMarker := TMapMarkerDescriptor.Create(Position, 'MyMarker');
MyMarker.Draggable := True;
Mymarker.Icon := imagelist1.Bitmap(s,0);
MyMarker.Visible :=True;
Fmarkers.Add(MapView1.AddMarker(MyMarker));

Imagelist is a Timagelist on the form. added with a 16x16 image.

If i run my app, no marker is shown. do i comment // the line with the icon then all works fine but i have no custom marker icon.

i want a set of 4 different marker icons.

2
What is your variable s declared as?MartynA
s is TSizeF by my testing and researching about this problem. I can get custom icon by using TImage but not with imagelist, i continue my researchHenrikki

2 Answers

1
votes

TSizeF.Create returns an instance of the record, which you must save into your variable s. This should work (presuming you have a 16x16 bitmap at index 0 in your ImageList):

s := TSizeF.Create(16, 16);            //Image size
position.Latitude := mapview1.Location.Latitude;
position.Longitude := mapview1.Location.Longitude;
MyMarker := TMapMarkerDescriptor.Create(Position, 'MyMarker');
MyMarker.Draggable := True;
Mymarker.Icon := imagelist1.Bitmap(s, 0);
MyMarker.Visible :=True;
Fmarkers.Add(MapView1.AddMarker(MyMarker));

You should also be able to just skip the creation into a different variable and use it directly from the constructor [untested] - TSizeF is a record, and therefore doesn't need to be destroyed:

MyMarker.Icon := ImageList1.Bitmap(TSizeF.Create(16, 16), 0);
-1
votes

Well i have been looking answer for the same thing now for long time and the only way i could change it was loading my png image to TImage component on Designer and then assign Bitmap from that. Like this:

MyMarker.Icon := Image1.Bitmap;

Also the size of the picture doesn't matter

Update:
I found a way to put custom icon from imagelist

s.Create(16, 16); //Image size
position.Latitude := mapview1.Location.Latitude;
position.Longitude := mapview1.Location.Longitude;
MyMarker := TMapMarkerDescriptor.Create(Position, 'MyMarker');
MyMarker.Draggable := True;
MyMarker.Icon := ImageList1.Source.Items[0].MultiResBitmap.Items[0].Bitmap;
MyMarker.Visible :=True;
Fmarkers.Add(MapView1.AddMarker(MyMarker));