Delphi Can
Mapview mark rotate sorunu - Baskı Önizleme

+- Delphi Can (https://www.delphican.com)
+-- Forum: Delphi (https://www.delphican.com/forumdisplay.php?fid=3)
+--- Forum: Mobil Platform - FireMonkey (FMX) (https://www.delphican.com/forumdisplay.php?fid=7)
+--- Konu Başlığı: Mapview mark rotate sorunu (/showthread.php?tid=6583)

Sayfalar: 1 2


Mapview mark rotate sorunu - arsl01 - 31-01-2022

Merhaba,
Haritada basit bir şekilde  "TMapMarker" ekliyorum, Marker'ın rotate özelliği android de çalışıyor fakat ios kısmın da çalışmıyor.

Örnek Kod'u paylaştım. Manuel olarak 0, 45, 90 gibi değerler versem de ios kısmın da tepki yok.



var
MyMarker: TMapMarkerDescriptor;
Derece:integer;
begin
 MyMarker := TMapMarkerDescriptor.Create(Position, 'Here');
 MyMarker.Icon := ImageList2.Bitmap(TSizeF.Create(64, 64), 10);
 Derece:= derecehesapla();
 MyMarker.Rotation := Derece;

 MyMarker.Draggable := false;
 MyMarker.Visible := true;
 MyMarker.Title := baslik;
 MyMarker.Snippet := '(' + Position.Latitude.ToString + ' - ' +
   Position.Longitude.ToString + ')';
 Yer := MapView1.AddMarker(MyMarker);
 FMarkersboat.add(Yer);
end;



Cvp: Mapview mark rotate sorunu - RAD Coder - 31-01-2022

iOS tarafına baktığımızda; farklı olarak groundAnchor özelliğinin set edildiğini görüyoruz. 
Delphi tarafında groundAnchor özelliğine karşılık gelen property, sanırım TMapMarkerDescriptor record'unun Origin özelliğidir. 
Rotation özelliğinden hemen önce aşağıdaki bir bir atama yapın.
MyMarker.Origin := TPointF.Create(0.5, 0.5);



Mapview mark rotate sorunu - arsl01 - 31-01-2022

Dediğiniz gibi Rotation özelliğinden hemen önce kullandım fakat halen rotation özelliği değişmiyor.

Kod:
Marker perth = mMap.addMarker(new MarkerOptions()
                     .position(PERTH)
                     .flat(true));

flat değerini true yapınca sorun çözülmüş fakaat delphi tarafında flat karşılını bulamıyorum.
kaynak


Cvp: Mapview mark rotate sorunu - RAD Coder - 31-01-2022

FMX.Map.iOS unit'inde Origin değerinden 0.5 çıkarılıyor. 
Bunu deden yapıyor bilmiyorum.
Söz konusu Unit'teki ilgili kısım:
function TMapKitMapMarker.AnnotationView: MKAnnotationView;
var
 Pin: MKPinAnnotationView;
 Image: UIImage;
begin
 if FAnnotationView <> nil then
   Exit(FAnnotationView);

 if Descriptor.Icon <> nil then
 begin
   Result := TMKAnnotationView.Wrap(TMKAnnotationView.Alloc.initWithAnnotation((FAnnotation as ILocalObject).GetObjectID,
     nil));
   Image := BitmapToUIImage(Descriptor.Icon);
   Result.setImage(Image);
   Result.setUserInteractionEnabled(Descriptor.Draggable);
   Result.setDraggable(Descriptor.Draggable);
   Result.setCanShowCallout(True);
   Result.setCenterOffset(CGPointMake(Image.size.width * (Descriptor.Origin.X - 0.5),
     - Image.size.height * (Descriptor.Origin.Y - 0.5)));
 end
 else
 begin
   Pin := TMKPinAnnotationView.Wrap(TMKPinAnnotationView.Alloc.initWithAnnotation((FAnnotation as ILocalObject).GetObjectID,
     nil));
   Pin.setUserInteractionEnabled(Descriptor.Draggable);
   Pin.setCanShowCallout(True);
   Pin.setDraggable(Descriptor.Draggable);
   Pin.setUserInteractionEnabled(Descriptor.Draggable);
   Result := Pin;
 end;
 FAnnotationView := Result;
end;


0.5 çıkarıldığına göre siz bu değeri 1,1 olarak gönderin.


Mapview mark rotate sorunu - arsl01 - 31-01-2022

Denedim, sonuç değişmedi fakat marker'ın olması gereken yerden sağ tarafa saptı.


Cvp: Mapview mark rotate sorunu - RAD Coder - 31-01-2022

Flat özelliğini aşağıdaki şekilde set edebilirsiniz.
MyMarker.Appearance := TMarkerAppearance.Flat;



Mapview mark rotate sorunu - arsl01 - 31-01-2022

MyMarker.Appearance := TMarkerAppearance.Flat;

MyMarker.Appearance := TMarkerAppearance.Billboard;

bu şekilde ikisini de denedim, malesef sorun aynı.

Geçici çözüm olarak mapview'in Beraing özelliğini kullanacağım, GestureOptions'dan ise rotate özelliğini kaldıracağım.


Cvp: Mapview mark rotate sorunu - RAD Coder - 31-01-2022

Android, iOS ve her iki platformun base class'ındaki ortak atamalarına bakalım.
Android tarafında:
function TAndroidMapView.BuildMarkerOptions(const D: TMapMarkerDescriptor): JMarkerOptions;
begin
 Result := TJMarkerOptions.JavaClass.init.alpha(D.Opacity)
   .anchor(D.Origin.X, D.Origin.Y)
   .draggable(D.Draggable)
   .flat(D.Appearance = TMarkerAppearance.Flat)
   .position(CoordToLatLng(D.Position))
   .rotation(D.Rotation)
   .snippet(StringToJString(D.Snippet))
   .title(StringToJString(D.Title))
   .visible(D.Visible);
 if D.Icon <> nil then
   Result := Result.icon(CreateBitmapDescriptorFromBitmap(D.Icon));
end;

iOS Tarafında:
function TMapKitMapMarker.AnnotationView: MKAnnotationView;
var
 Pin: MKPinAnnotationView;
 Image: UIImage;
begin
 if FAnnotationView <> nil then
   Exit(FAnnotationView);

 if Descriptor.Icon <> nil then
 begin
   Result := TMKAnnotationView.Wrap(TMKAnnotationView.Alloc.initWithAnnotation((FAnnotation as ILocalObject).GetObjectID,
     nil));
   Image := BitmapToUIImage(Descriptor.Icon);
   Result.setImage(Image);
   Result.setUserInteractionEnabled(Descriptor.Draggable);
   Result.setDraggable(Descriptor.Draggable);
   Result.setCanShowCallout(True);
   Result.setCenterOffset(CGPointMake(Image.size.width * (Descriptor.Origin.X - 0.5),
     - Image.size.height * (Descriptor.Origin.Y - 0.5)));
 end
 else
 begin
   Pin := TMKPinAnnotationView.Wrap(TMKPinAnnotationView.Alloc.initWithAnnotation((FAnnotation as ILocalObject).GetObjectID,
     nil));
   Pin.setUserInteractionEnabled(Descriptor.Draggable);
   Pin.setCanShowCallout(True);
   Pin.setDraggable(Descriptor.Draggable);
   Pin.setUserInteractionEnabled(Descriptor.Draggable);
   Result := Pin;
 end;
 FAnnotationView := Result;
end;

Map ortak sınıfında:
class function TMapMarkerDescriptor.Create(const Position: TMapCoordinate; const Title: string): TMapMarkerDescriptor;
begin
 Result.Position := Position;
 Result.Title := Title;
 Result.Opacity := 1;
 Result.Origin := TPointF.Create(0.5, 1);
 Result.Snippet := string.Empty;
 Result.Draggable := False;
 Result.Visible := True;
 Result.Appearance := TMarkerAppearance.Flat;
 Result.Rotation := 0;
 Result.Icon := nil;
end;

Yukarıdaki temel atamalara baktığımızda; marker yönünün Origin (anchor) ve Flat özellikleri ile ilgili olduğunu görüyoruz. Siz her ne kadar set etseniz de durum değişmediğine göre kodlarınızda bir sorun yok demektir. 
Embercadero comminity'e bu durumu bildirmekten başka çare görünmüyor.


Cvp: Mapview mark rotate sorunu - arsl01 - 31-01-2022

(31-01-2022, Saat: 12:13)RAD Coder Adlı Kullanıcıdan Alıntı: Android, iOS ve her iki platformun base class'ındaki ortak atamalarına bakalım.
Android tarafında:
function TAndroidMapView.BuildMarkerOptions(const D: TMapMarkerDescriptor): JMarkerOptions;
begin
 Result := TJMarkerOptions.JavaClass.init.alpha(D.Opacity)
   .anchor(D.Origin.X, D.Origin.Y)
   .draggable(D.Draggable)
   .flat(D.Appearance = TMarkerAppearance.Flat)
   .position(CoordToLatLng(D.Position))
   .rotation(D.Rotation)
   .snippet(StringToJString(D.Snippet))
   .title(StringToJString(D.Title))
   .visible(D.Visible);
 if D.Icon <> nil then
   Result := Result.icon(CreateBitmapDescriptorFromBitmap(D.Icon));
end;

iOS Tarafında:
function TMapKitMapMarker.AnnotationView: MKAnnotationView;
var
 Pin: MKPinAnnotationView;
 Image: UIImage;
begin
 if FAnnotationView <> nil then
   Exit(FAnnotationView);

 if Descriptor.Icon <> nil then
 begin
   Result := TMKAnnotationView.Wrap(TMKAnnotationView.Alloc.initWithAnnotation((FAnnotation as ILocalObject).GetObjectID,
     nil));
   Image := BitmapToUIImage(Descriptor.Icon);
   Result.setImage(Image);
   Result.setUserInteractionEnabled(Descriptor.Draggable);
   Result.setDraggable(Descriptor.Draggable);
   Result.setCanShowCallout(True);
   Result.setCenterOffset(CGPointMake(Image.size.width * (Descriptor.Origin.X - 0.5),
     - Image.size.height * (Descriptor.Origin.Y - 0.5)));
 end
 else
 begin
   Pin := TMKPinAnnotationView.Wrap(TMKPinAnnotationView.Alloc.initWithAnnotation((FAnnotation as ILocalObject).GetObjectID,
     nil));
   Pin.setUserInteractionEnabled(Descriptor.Draggable);
   Pin.setCanShowCallout(True);
   Pin.setDraggable(Descriptor.Draggable);
   Pin.setUserInteractionEnabled(Descriptor.Draggable);
   Result := Pin;
 end;
 FAnnotationView := Result;
end;

Map ortak sınıfında:
class function TMapMarkerDescriptor.Create(const Position: TMapCoordinate; const Title: string): TMapMarkerDescriptor;
begin
 Result.Position := Position;
 Result.Title := Title;
 Result.Opacity := 1;
 Result.Origin := TPointF.Create(0.5, 1);
 Result.Snippet := string.Empty;
 Result.Draggable := False;
 Result.Visible := True;
 Result.Appearance := TMarkerAppearance.Flat;
 Result.Rotation := 0;
 Result.Icon := nil;
end;

Yukarıdaki temel atamalara baktığımızda; marker yönünün Origin (anchor) ve Flat özellikleri ile ilgili olduğunu görüyoruz. Siz her ne kadar set etseniz de durum değişmediğine göre kodlarınızda bir sorun yok demektir. 
Embercadero comminity'e bu durumu bildirmekten başka çare görünmüyor.

Evet hocam, bu durumu Embercadero comminity'e bildireceğim, teşekkür ederim yardımlarınız için.


Mapview mark rotate sorunu - arsl01 - 01-02-2022

@RAD Coder  hocam kullandığınız Delphi sürümu 11 ise test edip sonucu paylaşma şansınız var mı? Bu sorun belki 11 sürümünde düzeltilmiştir.