kb0 / maps_toolkit

Dart library for area, distance, heading measurements
Apache License 2.0
46 stars 17 forks source link

I'm not able to use google maps flutter LatLng in map_toolkit #7

Closed nani-samireddy closed 4 years ago

nani-samireddy commented 4 years ago

I'm developing an application in which i have check the user selected point is inside a polygon or not!!.. Then I created a polygon and took a point for the map selected by the user. now I would like to use map_toolkit to check whether the given point is inside a polygon or not. When I trying to pass the User selected LatLng as the parameter to the function PolygonUtil.containsLocation()...

bool rsult = maps_toolkit.PolygonUtil.containsLocation(point, TOTAL_COVERAGE, false);

point is a LatLng value that s taken from the google maps flutter. it is giving an error when I hover it as follows

LatLng point The argument type 'LatLng (where LatLng is defined in C:\Users\NANI\AppData\Local\Pub\Cache\hosted\pub.dartlang.org\google_maps_flutter_platform_interface-1.0.4\lib\src\types\location.dart)' can't be assigned to the parameter type 'LatLng (where LatLng is defined in C:\Users\NANI\AppData\Local\Pub\Cache\hosted\pub.dartlang.org\maps_toolkit-1.1.0+2\lib\src\latlng.dart)'.dartargument_type_not_assignable location.dart(10, 7): LatLng is defined in C:\Users\NANI\AppData\Local\Pub\Cache\hosted\pub.dartlang.org\google_maps_flutter_platform_interface-1.0.4\lib\src\types\location.dart latlng.dart(1, 7): LatLng is defined in C:\Users\NANI\AppData\Local\Pub\Cache\hosted\pub.dartlang.org\maps_toolkit-1.1.0+2\lib\src\latlng.dart

kb0 commented 4 years ago

Yes, you cannot use Google Maps LatLng directly. You should convert Google Maps LatLng into Maps Toolkit LatLng, for ex.:

import 'package:maps_toolkit/maps_toolkit.dart' as mp;
import 'package:google_maps/google_maps.dart';
import 'package:test/test.dart';

void main() {
  final pointFromGoogleMap = LatLng(90, 0);
  final pointMp = mp.LatLng(pointFromGoogleMap.lat, pointFromGoogleMap.lng);

  bool result = mp.PolygonUtil.containsLocation(pointMp, TOTAL_COVERAGE, false);
}
nani-samireddy commented 4 years ago

Yes I've solved it in the same way. Now I want to know that have you ever used Google s2 geometry .. If yes please reply 🥺🥺🥺

kb0 commented 4 years ago

No. Never use S2 geometry

nani-samireddy commented 4 years ago

Do you know how to implement that...

faqcodes commented 1 year ago

I have a list: List that use in flutter_map. But, I can't use in "mp.PolygonUtil.containsLocation" for the same error :-(