Giter VIP home page Giter VIP logo

maps_toolkit's People

Contributors

bartoszpijet avatar cdfq152313 avatar edgarfroes avatar kb0 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

maps_toolkit's Issues

PolygonUtil.decode is broken on web

A decoded polyline that works fine on iOS and Android, is fully broken on web.
It will turn into one or more straight lines.

This is an Android emulator (left) next to Chrome (right).
polyline

I've use this polyline in the screenshot above.

u|ywHi_za@cM{U}PcIaB~@a@Vi@Fs@Pw@x@o@rAsD_HGcCy@l@oBpBMNi@f@URoAnASVqBzAuAd@eANgCIa@?k@DHXFp@aAn@eA]o@j@qAbBqAvB}A~Ci@`BQv@_@z@eB`C_@v@c@rAy@vAoBvCqCvD{@|@WNw@HSh@_@z@uAr@e@b@i@sAGq@Eu@CmBqAy@}@u@YMwAyAc@cAeAoDjAuAbFuIfBaCeBqFOi@cA}I?gADw@RcBLkBJcE?wCJQY_EH}DuA}HoBuGgDiEi@m@][q@a@m@Qm@IiB?UHUk@mBeIOeAAkABs@r@iEtB}RLcBQIo@i@oAeBg@}@UUoBuC_@[u@[}B_@qCmAq@QU[CL[JuBGa@I{@Gk@d@MRWJa@MK_AN_@?g@IkAQa@GR}HhIq@Ri@Ja@@mAM_A]aAm@iA[KFmAyAgAyBEa@Eg@JaAZi@xAqB~AmCrAuC|BoEFQdBuDNWXq@v@wA\\a@_@kA_@yB_@wAm@sAXeAIuLMyGMiE^Ef@_@t@y@pCgCnBoCnAM|@KnBgBPGDx@Ob@\\tEVl@~M}Cp@@LLvAShAa@|@u@d@Yn@Ux@GZ@C{BQwBUgCaAoIWwD?_@H@pIo@d@G~@?bBz@tAxA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BCdBIv@]zAqBdHKt@CjA`BpQ@|B?pFJ~CHdAT`BhApF\\hCr@xH^~FV~G@bGCbHAdG?n@_@h@YjAkAxGuAzIa@zA}ArFa@vA[t@a@j@{EhFBx@@vFHb@BXDp@Cz@MjDA|CF~@dArQOfAMdAqErc@wK_FmLyFm@Uo@CeCA{JmIyEoDqBkDsBw@uBm@CjBqAzOO~ASpAYbA_DvHMj@YnBUjEQvA_@nAs@zBWU}BoBq@kBgA{E]g@aAHg@AiGmAiABoBd@cDTiA?aD]kAHqD|@eB`@sAJ@~FDvBLnBPxAVdAh@p@V^N^r@pCl@z@|@n@Xb@~@vBjC~DVt@sFnG_@Pe@Fa@EsD_@cCQUe@_@?Un@u@JuBT{BJqCPgCOwBBoBZcAA{@QgAc@m@Sw@BmBH}Bo@aCc@oCUiACcAUi@_@]GWqB]}BUeAWq@c@_@uB{BW@In@EtAKbAm@@_Ao@eGwIv@kDKsDoDsRsAgBuJp@gF`AkBz@

This exact issue was reported before, but using flutter_polyline_points instead. flutter/flutter#86349

The issue is related to how bitwise operations are compiled to javascript. The solution in the other plugin was to use BigInt.
Dammyololade/flutter_polyline_points#40 (comment)

Unable to use package

Can't use
import 'package:google_maps_flutter/google_maps_flutter.dart';
&
import 'package:maps_toolkit/maps_toolkit.dart'; in the same dart file. The existing LatLng class is throwing error.

how to update and calculate distance in polyline[help]

I am designing a navigation system for my app, but my problem is that I want to redraw the polyline from the user's point and calculate the new line spacing like navigation. I find the current position in a multiline using the locationIndexOnEdgeOrPath method, remove the previous positions, add the user's location to the beginning of the multiline, and redraw the multiline, in 50% of cases a little line forward or it is drawn back and also polyline distance is wrong

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

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

can't be assigned to the parameter type latlong2 package

i have this problem when use SphericalUtil.computeArea :

The argument type 'List (where LatLng is defined in ...\flutter.pub-cache\hosted\pub.dartlang.org\latlong2-0.8.1\lib\latlong\LatLng.dart)' can't be assigned to the parameter type 'List (where LatLng is defined in ...\flutter.pub-cache\hosted\pub.dartlang.org\maps_toolkit-2.0.0\lib\src\latlng.dart)

Is there a solution to using both types of latlang ?

The argument type 'LatLong' can't be assigned to the parameter type 'LatLng'

I've seen a similar issue here that is marked as closed but I am not able to solve this. I use google_maps_flutter that uses LatLong class for latitude and longitude.
This package uses LatLng class for latitude and longitude.

Because of this a lot of functionalities are incompatible. So for example if I want to use:
PolygonUtil.isLocationOnPath(point, polyline, geodesic)
It expects LatLng for point and the List of LatLng of polylines. Because I'm getting LatLong from google_maps_flutter I get the error: The argument type 'LatLong' can't be assigned to the parameter type 'LatLng'.

Is there way to transform LatLong to LatLng and vice-versa?

isLocationOnPath set TOLERANCE

Hi ,

This is a great port.

But i wonder how can we change the default tolerance value ?

PolygonUtil.isLocationOnPath takes only 3 arguments.

Polygones intersection

Any idea howa to get the intesection between the blue polygon and the grey one ? Thanks

608A5517-EF85-4600-B218-07AD4C32A0E3

geodesic?

PolygonUtil.containsLocation - what does geodesic parameter mean? Should it be true or false?
I just want to check if my position is inside polygon or not

PolygonUtil.containsLocation

PolygonUtil.containsLocation sending wrong output. I want to check my current location is into the polygon or not. I draw the polygon by using some latlng which are got from backend. Now sending the same vertices to containsLocation method and current location. On google map my cursor in polygon but this method sending false output. Please let me know the solution over this

Getting the corners of a square gives mixed results

Hi.

I am trying to draw several square polygons on Google Maps and I am getting mixed results. For some coordinates it's drawing a perfect square and for others it's clearly a rectangle. I'm just computing the 4 corners and passing them to Google Maps to draw the polygons. What could be the cause? Am I missing something? The coordinates are very close together in the same neighbourhood in Bucharest, Romania.

List<sp.LatLng> getMiniSquarePolygon(int position) {
    const double latLen = 1; // metres
    final sp.LatLng topLeftCorner = <INITIAL COORDINATES>;
    final sp.LatLng topRightCorner = sp.SphericalUtil.computeOffset(
        topLeftCorner, latLen / cos(topLeftCorner.latitude), 90);
    final sp.LatLng bottomRightCorner =
        sp.SphericalUtil.computeOffset(topRightCorner, latLen, 180);
    final sp.LatLng bottomLeftCorner = sp.SphericalUtil.computeOffset(
        bottomRightCorner, latLen / cos(bottomRightCorner.latitude), 270);
    return <LatLng>[
      topLeftCorner,
      topRightCorner,
      bottomRightCorner,
      bottomLeftCorner,
      topLeftCorner,
    ];
  }

flutter_3

Change Earth Radius

The SphericalUitl & PolygonUtil class contains the incorrect earth radius, change it from 6371009.0 to 6378137.0.
The results will be the same as lib javascript V3.

How to check distance from point to polygon (area)?

I have a polygon that consists of an array of points. I have a point that is outside this polygon. how can I find the closest distance between a point and a polygon?

I have one option so far:
1.Calculate the distance between each polygon point and the outer point
2. find the nearest point, find an adjacent one for it (line).
3. Calculate the distance between the line and the outside point(using distanceToLine).

but it seems complicated to me. maybe there is an easier solution?

to check if the retrieved points are inside polygon

I started by checking if the point is inside polygon and it worked well. my goal is to allow a user to draw a polygon then to use that list to check if there is any point that is inside drawn polygon. I archeved to allow user draw the polygon now I want to check if there is any point inside that polygon.

the list of latLang that make the polygon is
List<LatLng> _userPolyLinesLatLngList = [];

i want to create new list that i can use for map tool kit that List should have LatLang from above list.

Help me to convert that List so as I can assign as List of latlang for toolkit. therefore what I want is two variable of List the above List and new List that i can use on toolkit to check if the point is inside the polygon.

         ` //something like this
          List<LatLng> _userPolyLinesLatLngList = [];
          List<mp.LatLng> newListForToolKit = _userPolyLinesLatLngList;
          //this brings error` //then 
          final points = mp.PolygonUtil.containsLocation(
              mp.LatLng(-6.7924, 39.2083), newListForToolKit, true);

              `

And Here are the complete code that allow user to draw polygon. I want to check if the point is inside polygon.
`import 'dart:async';
import 'dart:collection';
import 'dart:convert';
import 'dart:io';
import 'dart:math' as Math;

import 'package:flutter/material.dart';
import 'package:geocoding/geocoding.dart';
import 'package:google_maps_flutter/google_maps_flutter.dart';
import 'package:maps_toolkit/maps_toolkit.dart' as mp;

class MyHomePageMap extends StatefulWidget {
MyHomePageMap({Key? key}) : super(key: key);

@OverRide
_MyHomePageMapState createState() => _MyHomePageMapState();
}

class _MyHomePageMapState extends State {
static final Completer _controller = Completer();

static final CameraPosition _kGooglePlex = CameraPosition(
target: LatLng(37.42796133580664, -122.085749655962),
zoom: 14.4746,
);

final Set _polygons = HashSet();
final Set _polyLines = HashSet();

bool _drawPolygonEnabled = false;
List _userPolyLinesLatLngList = [];
// List<mp.LatLng> _userPolyLinesLatLngListsUser = [];

final pointFromGoogleMap = LatLng(90, 0);

bool _clearDrawing = false;
int? _lastXCoordinate, _lastYCoordinate;

var distanceBetweenPoints = mp.SphericalUtil.computeDistanceBetween(
mp.LatLng(51.5073509, -0.1277583), mp.LatLng(48.856614, 2.3522219));

final cityLondon = mp.LatLng(51.5073509, -0.1277583);
final cityParis = mp.LatLng(48.856614, 2.3522219);

final distance = mp.SphericalUtil.computeDistanceBetween(
mp.LatLng(51.5073509, -0.1277583), mp.LatLng(48.856614, 2.3522219)) /
1000.0;
// List polygony = [
// (37.43296265331129, -122.08832357078792),
// (37.43006265331129, -122.08832357078792),
// (37.43006265331129, -122.08332357078792),

// ];

// print('Distance between London and Paris is $distance km.');
// PolygonUtil.containsLocation - computes whether the given point lies inside the specified polygon.
// final distances = mp.SphericalUtil.computeDistanceBetween(mp.LatLng(51.5073509, -0.1277583), 4.3)

List<mp.LatLng> polygonCoord = [
mp.LatLng(37.43296265331129, -122.08832357078792),
mp.LatLng(37.43006265331129, -122.08832357078792),
mp.LatLng(37.43006265331129, -122.08332357078792),
mp.LatLng(37.43296265331129, -122.08832357078792)
];

@OverRide
Widget build(BuildContext context) {
return Scaffold(
body: GestureDetector(
onPanUpdate: (_drawPolygonEnabled) ? _onPanUpdate : null,
onPanEnd: (_drawPolygonEnabled) ? _onPanEnd : null,
child: GoogleMap(
mapType: MapType.normal,
initialCameraPosition: _kGooglePlex,
polygons: _polygons,
polylines: _polyLines,
onMapCreated: (GoogleMapController controller) {
_controller.complete(controller);
},
),
),
floatingActionButton: Column(
mainAxisAlignment: MainAxisAlignment.end,
children: [
FloatingActionButton(
onPressed: () {
print("The DISTANCE IS $distance");
final points = mp.PolygonUtil.containsLocation(
mp.LatLng(-6.7924, 39.2083), polygonCoord, true);
print("The POIT IS FOUND ON THE FOLLOWING $points");
// final a = mp._userPolyLinesLatLngList;
// print("The POIT IS FOUND ON THE FOLLOWING $a YES");

          List<mp.LatLng> polygonCoords = [
            mp.LatLng(37.43296265331129, -122.08832357078792),
            mp.LatLng(37.43006265331129, -122.08832357078792),
            mp.LatLng(37.43006265331129, -122.08332357078792),
            mp.LatLng(37.43296265331129, -122.08832357078792)
          ];
          List<LatLng> _userPolyLinesLatLngList = [];
          // ignore: unused_local_variable
          double a, b;

          // var b;
          // var lat;
          // List<mp.LatLng> _userPolyLinesLatLngListsUser =
          //     _userPolyLinesLatLngList;

          final pointFromGoogleMap = LatLng(90, 0);
          final pointMp = mp.LatLng(
              pointFromGoogleMap.latitude, pointFromGoogleMap.longitude);

          print("The POIT IS FOUND ON THE FOLLOWING $points YES");
          if (points == true) {
            print("The POIT IS FOUND ON THE FOLLOWING $points YES");
          } else {
            print("The POIT IS FOUND ON THE FOLLOWING $points No");
          }
        },
        tooltip: 'Drawing',
        child: Icon(Icons.menu),
      ),
      FloatingActionButton(
        onPressed: _toggleDrawing,
        tooltip: 'Drawing',
        child: Icon((_drawPolygonEnabled) ? Icons.cancel : Icons.edit),
      ),
    ],
  ),
);

}

_toggleDrawing() {
_clearPolygons();
setState(() => _drawPolygonEnabled = !_drawPolygonEnabled);
}

_onPanUpdate(DragUpdateDetails details) async {
// To start draw new polygon every time.
if (_clearDrawing) {
_clearDrawing = false;
_clearPolygons();
}

if (_drawPolygonEnabled) {
  double? x, y;
  if (Platform.isAndroid) {
    // It times in 3 without any meaning,
    // We think it's an issue with GoogleMaps package.
    x = details.globalPosition.dx * 3;
    y = details.globalPosition.dy * 3;
  } else if (Platform.isIOS) {
    x = details.globalPosition.dx;
    y = details.globalPosition.dy;
  }

  // Round the x and y.
  int xCoordinate = x!.round();
  int yCoordinate = y!.round();

  // Check if the distance between last point is not too far.
  // to prevent two fingers drawing.
  if (_lastXCoordinate != null && _lastYCoordinate != null) {
    var distance = Math.sqrt(Math.pow(xCoordinate - _lastXCoordinate!, 2) +
        Math.pow(yCoordinate - _lastYCoordinate!, 2));
    // Check if the distance of point and point is large.
    if (distance > 80.0) return;
  }

  // Cached the coordinate.
  _lastXCoordinate = xCoordinate;
  _lastYCoordinate = yCoordinate;

  ScreenCoordinate screenCoordinate =
      ScreenCoordinate(x: xCoordinate, y: yCoordinate);

  final GoogleMapController controller = await _controller.future;
  LatLng latLng = await controller.getLatLng(screenCoordinate);
  // mp.LatLng latLngs = await controller.getLatLng(screenCoordinate);
  try {
    // Add new point to list.
    _userPolyLinesLatLngList.add(latLng);
    // _userPolyLinesLatLngListsUser.add(latLngs);

    _polyLines.removeWhere(
        (polyline) => polyline.polylineId.value == 'user_polyline');
    _polyLines.add(
      Polyline(
        polylineId: PolylineId('user_polyline'),
        points: _userPolyLinesLatLngList,
        width: 2,
        color: Colors.blue,
      ),
    );
  } catch (e) {
    print(" error painting $e");
  }
  setState(() {});
}

}

// 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);
// }

_onPanEnd(DragEndDetails details) async {
// Reset last cached coordinate
_lastXCoordinate = null;
_lastYCoordinate = null;

if (_drawPolygonEnabled) {
  _polygons
      .removeWhere((polygon) => polygon.polygonId.value == 'user_polygon');
  _polygons.add(
    Polygon(
      polygonId: PolygonId('user_polygon'),
      points: _userPolyLinesLatLngList,
      strokeWidth: 2,
      strokeColor: Colors.blue,
      fillColor: Colors.blue.withOpacity(0.4),
    ),
  );
  setState(() {
    _clearDrawing = true;
  });
}

}

_clearPolygons() {
setState(() {
_polyLines.clear();
_polygons.clear();
_userPolyLinesLatLngList.clear();
});
}
}
`

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.