Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import com.yandex.mapkit.layers.GeoObjectTapListener;
import com.yandex.mapkit.layers.ObjectEvent;
import com.yandex.mapkit.logo.Alignment;
import com.yandex.mapkit.logo.Padding;
import com.yandex.mapkit.logo.HorizontalAlignment;
import com.yandex.mapkit.logo.VerticalAlignment;
import com.yandex.mapkit.map.CameraPosition;
Expand Down Expand Up @@ -593,6 +594,10 @@ private void applyMapOptions(Map<String, Object> params) {
applyAlignLogo((Map<String, Object>) params.get("logoAlignment"));
}

if (params.get("logoPadding") != null) {
applyLogoPadding((Map<String, Object>) params.get("logoPadding"));
}

if (params.containsKey("focusRect")) {
applyFocusRect((Map<String, Object>) params.get("focusRect"));
}
Expand Down Expand Up @@ -630,6 +635,14 @@ private void applyAlignLogo(Map<String, Object> params) {
mapView.getMapWindow().getMap().getLogo().setAlignment(logoPosition);
}

private void applyLogoPadding(Map<String, Object> params) {
Padding logoPadding = new Padding(
(Integer) params.get("horizontal"),
(Integer) params.get("vertical")
);
mapView.getMapWindow().getMap().getLogo().setPadding(logoPadding);
}

private void applyFocusRect(Map<String, Object> params) {
if (params == null) {
mapView.getMapWindow().setFocusRect(null);
Expand Down
12 changes: 12 additions & 0 deletions ios/Classes/lite/YandexMapController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,10 @@ public class YandexMapController:
applyAlignLogo(logoAlignment)
}

if let logoPadding = params["logoPadding"] as? [String: Any] {
applyLogoPadding(logoPadding)
}

if params.keys.contains("focusRect") {
applyFocusRect(params["focusRect"] as? [String: Any])
}
Expand Down Expand Up @@ -515,6 +519,14 @@ public class YandexMapController:
mapView.mapWindow.map.logo.setAlignmentWith(logoPosition)
}

private func applyLogoPadding(_ params: [String: Any]) {
let logoPadding = YMKLogoPadding(
horizontalPadding: (params["horizontal"] as! NSNumber).uintValue,
verticalPadding: (params["vertical"] as! NSNumber).uintValue
)
mapView.mapWindow.map.logo.setPaddingWith(logoPadding)
}

private func applyFocusRect(_ params: [String: Any]?) {
if (params == nil) {
mapView.mapWindow.focusRect = nil
Expand Down
31 changes: 31 additions & 0 deletions lib/src/types/map_padding.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
part of '../../yandex_mapkit.dart';

/// Map logo padding.
class MapPadding extends Equatable {
const MapPadding({
required this.horizontal,
required this.vertical,
});

/// The horizontal padding.
final int horizontal;

/// The vertical padding.
final int vertical;

@override
List<Object> get props => <Object>[
horizontal,
vertical,
];

@override
bool get stringify => true;

Map<String, dynamic> toJson() {
return {
'horizontal': horizontal,
'vertical': vertical,
};
}
}
8 changes: 8 additions & 0 deletions lib/src/yandex_map.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class YandexMap extends StatefulWidget {
this.fastTapEnabled = false,
this.mode2DEnabled = false,
this.logoAlignment = const MapAlignment(horizontal: HorizontalAlignment.right, vertical: VerticalAlignment.bottom),
this.logoPadding,
this.focusRect,
this.onMapCreated,
this.onMapTap,
Expand Down Expand Up @@ -79,6 +80,9 @@ class YandexMap extends StatefulWidget {
/// Set logo alignment on the map
final MapAlignment logoAlignment;

/// The logo padding on the map.
final MapPadding? logoPadding;

/// Allows to set map focus to a certain rectangle instead of the whole map
/// For more info refer to https://yandex.com/dev/maps/mapkit/doc/ios-ref/full/Classes/YMKMapWindow.html#focusRect
final ScreenRect? focusRect;
Expand Down Expand Up @@ -279,6 +283,7 @@ class _YandexMapOptions {
fastTapEnabled = map.fastTapEnabled,
mode2DEnabled = map.mode2DEnabled,
logoAlignment = map.logoAlignment,
logoPadding = map.logoPadding,
focusRect = map.focusRect,
mapType = map.mapType,
poiLimit = map.poiLimit,
Expand All @@ -300,6 +305,8 @@ class _YandexMapOptions {

final MapAlignment logoAlignment;

final MapPadding? logoPadding;

final ScreenRect? focusRect;

final MapType mapType;
Expand All @@ -318,6 +325,7 @@ class _YandexMapOptions {
'fastTapEnabled': fastTapEnabled,
'mode2DEnabled': mode2DEnabled,
'logoAlignment': logoAlignment.toJson(),
'logoPadding': logoPadding?.toJson(),
'focusRect': focusRect?.toJson(),
'mapType': mapType.index,
'poiLimit': poiLimit,
Expand Down
1 change: 1 addition & 0 deletions lib/yandex_mapkit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ part 'src/types/driving/driving_section_metadata.dart';
part 'src/types/driving/driving_session.dart';
part 'src/types/localized_value.dart';
part 'src/types/map_alignment.dart';
part 'src/types/map_padding.dart';
part 'src/types/map_animation.dart';
part 'src/types/map_objects/circle_map_object.dart';
part 'src/types/map_objects/clusterized_placemark_collection.dart';
Expand Down