release 1.0.3
This commit is contained in:
@ -1,3 +1,15 @@
|
||||
// Copyright 2023-2024 kuloud
|
||||
// Copyright 2020 lbs.amap.com
|
||||
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
|
||||
part of amap_map;
|
||||
|
||||
final MethodChannelAMapFlutterMap _methodChannel =
|
||||
@ -124,4 +136,14 @@ class AMapController {
|
||||
Future<void> clearDisk() {
|
||||
return _methodChannel.clearDisk(mapId: mapId);
|
||||
}
|
||||
|
||||
/// 经纬度转屏幕坐标
|
||||
Future<ScreenCoordinate> toScreenCoordinate(LatLng latLng) {
|
||||
return _methodChannel.toScreenLocation(latLng, mapId: mapId);
|
||||
}
|
||||
|
||||
/// 屏幕坐标转经纬度
|
||||
Future<LatLng> fromScreenCoordinate(ScreenCoordinate screenCoordinate) {
|
||||
return _methodChannel.fromScreenLocation(screenCoordinate, mapId: mapId);
|
||||
}
|
||||
}
|
||||
|
@ -1,3 +1,14 @@
|
||||
// Copyright 2023-2024 kuloud
|
||||
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
|
||||
part of amap_map;
|
||||
|
||||
class AMapLoader extends StatefulWidget {
|
||||
|
@ -1,4 +1,17 @@
|
||||
// Copyright 2023-2024 kuloud
|
||||
// Copyright 2020 lbs.amap.com
|
||||
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
|
||||
import 'dart:async';
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:x_amap_base/x_amap_base.dart';
|
||||
import 'package:amap_map/src/core/amap_flutter_platform.dart';
|
||||
@ -247,4 +260,24 @@ class MethodChannelAMapFlutterMap implements AMapFlutterPlatform {
|
||||
}) {
|
||||
return channel(mapId).invokeMethod<void>('map#clearDisk');
|
||||
}
|
||||
|
||||
Future<ScreenCoordinate> toScreenLocation(
|
||||
LatLng latLng, {
|
||||
required int mapId,
|
||||
}) async {
|
||||
final Map<String, int>? point = await channel(mapId)
|
||||
.invokeMapMethod<String, int>(
|
||||
'map#toScreenCoordinate', latLng.toJson());
|
||||
return ScreenCoordinate(x: point!['x']!, y: point['y']!);
|
||||
}
|
||||
|
||||
Future<LatLng> fromScreenLocation(
|
||||
ScreenCoordinate screenCoordinate, {
|
||||
required int mapId,
|
||||
}) async {
|
||||
final List<dynamic>? latLng = await channel(mapId)
|
||||
.invokeMethod<List<dynamic>>(
|
||||
'map#fromScreenCoordinate', screenCoordinate.toJson());
|
||||
return LatLng(latLng![0] as double, latLng[1] as double);
|
||||
}
|
||||
}
|
||||
|
44
lib/src/types/screen_coordinate.dart
Normal file
44
lib/src/types/screen_coordinate.dart
Normal file
@ -0,0 +1,44 @@
|
||||
// Copyright 2013 The Flutter Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'package:flutter/foundation.dart' show immutable, objectRuntimeType;
|
||||
|
||||
/// Represents a point coordinate in the [GoogleMap]'s view.
|
||||
///
|
||||
/// The screen location is specified in screen pixels (not display pixels) relative
|
||||
/// to the top left of the map, not top left of the whole screen. (x, y) = (0, 0)
|
||||
/// corresponds to top-left of the [GoogleMap] not the whole screen.
|
||||
@immutable
|
||||
class ScreenCoordinate {
|
||||
/// Creates an immutable representation of a point coordinate in the [GoogleMap]'s view.
|
||||
const ScreenCoordinate({
|
||||
required this.x,
|
||||
required this.y,
|
||||
});
|
||||
|
||||
/// Represents the number of pixels from the left of the [GoogleMap].
|
||||
final int x;
|
||||
|
||||
/// Represents the number of pixels from the top of the [GoogleMap].
|
||||
final int y;
|
||||
|
||||
/// Converts this object to something serializable in JSON.
|
||||
Object toJson() {
|
||||
return <String, int>{
|
||||
'x': x,
|
||||
'y': y,
|
||||
};
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() => '${objectRuntimeType(this, 'ScreenCoordinate')}($x, $y)';
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return other is ScreenCoordinate && other.x == x && other.y == y;
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(x, y);
|
||||
}
|
@ -1,3 +1,15 @@
|
||||
// Copyright 2023-2024 kuloud
|
||||
// Copyright 2020 lbs.amap.com
|
||||
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
|
||||
export 'camera.dart';
|
||||
export 'ui.dart';
|
||||
export 'base_overlay.dart';
|
||||
@ -10,3 +22,4 @@ export 'polygon_updates.dart';
|
||||
export 'bitmap.dart';
|
||||
export 'extension_context.dart';
|
||||
export 'amap_extension.dart';
|
||||
export 'screen_coordinate.dart';
|
||||
|
Reference in New Issue
Block a user