Giter Club home page Giter Club logo

osm_flutter's Introduction

flutter_osm_plugin

pub

Platform Support

Android iOS Web
supported ✔️ supported ✔️ (min iOS supported : 13) supported ✔️

osm plugin for flutter apps

  • current position (Android/iOS/web)
  • change position (Android/iOS/web)
  • create Marker manually (Android/iOS/web)
  • tracking user location (Android/iOS/web)
  • customize Icon Marker (Android/iOS/web)
  • customize user Marker (Android/iOS/web)
  • assisted selection position (Android/iOS)
  • set BoundingBox (Android/iOS/Web)
  • zoom into region (Android/iOS/web)
  • draw Road (Android/iOS/web)
  • recuperate information (instruction/duration/distance) of the current road (Android/iOS/web)
  • draw Road manually (Android/iOS/web)
  • draw multiple Roads (Android/iOS/web)
  • ClickListener on Marker (Android/iOS/web)
  • ClickListener on Map (Android/iOS/web)
  • calculate distance between 2 points
  • address suggestion
  • draw shapes (Android/iOS/web)
  • simple dialog location picker (Android/iOS)
  • listen to region change (Android/iOS/Web)
  • set custom tiles (Android/iOS/Web)

Getting Started

openStreetMap flutter examples

openStreetMap flutter examples

openStreetMap flutter examples

Installing

Add the following to your pubspec.yaml file:

dependencies:
  flutter_osm_plugin: ^1.0.4

Integration with Hooks

To use our map library with Flutter_Hooks library use our new extension library https://pub.dev/packages/osm_flutter_hooks many thanks for @ben-xD

Migration to 0.41.2 (Android Only)

open file build.gradle inside android file

* change kotlin version from `1.5.21` to `1.7.20`
* change gradle version from `7.0.4` to `7.1.3`
* change compileSdkVersion to 33

Migration to 0.34.0 (Android Only)

if you are using this plugin before Flutter 3

you should make some modification in build.gradle before that run flutter clean && flutter pub get

open file build.gradle inside android file

* change kotlin version from `1.5.21` to `1.6.21`
* change gradle version from `7.0.2` to `7.1.3` or `7.0.4`
* change compileSdkVersion to 32

Migration to 0.16.0 (Android Only)

if you are using this plugin before Flutter 2

you should make some modification in build.gradle before that run flutter clean && flutter pub get

open file build.gradle inside android file

* change kotlin version from `1.4.21` to `1.5.21`
* change gradle version from `4.1.1` to `7.0.2`

For web integration

To show buttons,UI that have to manage user click over the map, you should use this library : pointer_interceptor

Simple Usage

Creating a basic OSMFlutter :

 OSMFlutter( 
        controller:mapController,
        osmOption: OSMOption(
              userTrackingOption: UserTrackingOption(
              enableTracking: true,
              unFollowUser: false,
            ),
            zoomOption: ZoomOption(
                  initZoom: 8,
                  minZoomLevel: 3,
                  maxZoomLevel: 19,
                  stepZoom: 1.0,
            ),
            userLocationMarker: UserLocationMaker(
                personMarker: MarkerIcon(
                    icon: Icon(
                        Icons.location_history_rounded,
                        color: Colors.red,
                        size: 48,
                    ),
                ),
                directionArrowMarker: MarkerIcon(
                    icon: Icon(
                        Icons.double_arrow,
                        size: 48,
                    ),
                ),
            ),
            roadConfiguration: RoadOption(
                    roadColor: Colors.yellowAccent,
            ),
            markerOption: MarkerOption(
                defaultMarker: MarkerIcon(
                    icon: Icon(
                      Icons.person_pin_circle,
                      color: Colors.blue,
                      size: 56,
                    ),
                )
            ),
        )
    );

MapController

Declare MapController to control OSM map

1) Initialisation

Note using the default constructor, you should use initMapWithUserPosition or initPosition if you want the map to initialize using static position use the named constructor withPosition or if you want to initialize the map with user position use withUserPosition

// default constructor
 MapController controller = MapController(
                            initPosition: GeoPoint(latitude: 47.4358055, longitude: 8.4737324),
                            areaLimit: BoundingBox( 
                                east: 10.4922941, 
                                north: 47.8084648, 
                                south: 45.817995, 
                                west:  5.9559113,
                      ),
            );
// or set manually init position
 final controller = MapController.withPosition(
            initPosition: GeoPoint(
              latitude: 47.4358055,
              longitude: 8.4737324,
          ),
);
// init the position using the user location
final controller = MapController.withUserPosition(
        trackUserLocation: UserTrackingOption(
           enableTracking: true,
           unFollowUser: false,
        )
)

// init the position using the user location and control map from outside
final controller = MapController.withUserPosition(
        trackUserLocation: UserTrackingOption(
           enableTracking: true,
           unFollowUser: false,
        ),
         useExternalTracking: true
)

2) Dispose

     controller.dispose();

3) Properties of default MapController

MapController has 2 named Constructor MapController.withPosition, MapController.withUserPosition to control initialization of the Map

Properties Description
initMapWithUserPosition (UserTrackingOption?) initialize map with user position
initPosition (GeoPoint) if it isn't null, the map will be pointed at this position
areaLimit (Bounding) set area limit of the map (default BoundingBox.world())
customLayer (CustomTile) set customer layer using different osm server , this attribute used only with named constructor customLayer
useExternalTracking (bool) if true,we will disable our logic to show userlocation marker or to move to the user position

3.1) Custom Layers with MapController

  • To change the tile source in OSMFlutter, you should used our named constructor customLayer, see the example below
controller = MapController.customLayer(
      initPosition: GeoPoint(
        latitude: 47.4358055,
        longitude: 8.4737324,
      ),
      customTile: CustomTile(
        sourceName: "opentopomap",
        tileExtension: ".png",
        minZoomLevel: 2,
        maxZoomLevel: 19,
        urlsServers: [
         TileURLs(
            url: "https://tile.opentopomap.org/",
            subdomains: [],
          )
        ],
        tileSize: 256,
      ),
    )
  • also,you can use our predefined custom tiles like
  • cyclOSMLayer constructor for cycling tiles
  • publicTransportationLayer constructor for transport tiles ,it's public osm server

For more example see our example in home_example.dart

3.2) Change Layers in runtime

 await controller.changeTileLayer(tileLayer: CustomTile(...));

4) Set map on user current location

 await controller.currentLocation();

5) Zoom IN

 await controller.setZoom(stepZoom: 2);
 // or 
 await controller.zoomIn();

5.1) Zoom Out

 await controller.setZoom(stepZoom: -2);
 // or 
 await controller.zoomOut();
 

5.2) change zoom level

zoomLevel should be between minZoomLevel and maxZoomLevel

 await controller.setZoom(zoomLevel: 8);

5.3) zoom to specific bounding box

await controller.zoomToBoundingBox(BoundingBox(),paddingInPixel:0)
Note :
  • For the box attribute ,If you don't have bounding box,you can use list of geopoint like this BoundingBox.fromGeoPoints

6) get current zoom level b>

await controller.getZoom();

7) BoundingBox

set bounding box in the map

await controller.limitAreaMap(BoundingBox( east: 10.4922941, north: 47.8084648, south: 45.817995, west: 5.9559113,));

remove bounding box in the map

await controller.removeLimitAreaMap();

8) Track user current position

for iOS,you should add those line in your info.plist file

   <key>NSLocationWhenInUseUsageDescription</key>
	<string>any text you want</string>
	<key>NSLocationAlwaysUsageDescription</key>
	<string>any text you want</string>

from version 0.40.0 we can call only enableTracking will animate to user location without need to call currentLocation

when enableStopFollow is true,map will not be centered if the user location changed

you can disable rotation of personIcon using [disableUserMarkerRotation] (default: false)

 await controller.enableTracking(enableStopFollow:false,);

or

use this method below if you want to control the map(move to the user location and show the marker) while receiving the user location

 await controller.startLocationUpdating();

9) Disable tracking user position

 await controller.disabledTracking();

or

use this method below if you already used startLocationUpdating

 await controller.stopLocationUpdating();

10) update the location

Change the location without create marker

 await controller.moveTo(GeoPoint(latitude: 47.35387, longitude: 8.43609),animate:true);

11) recuperation current position

 GeoPoint geoPoint = await controller.myLocation();

12) get center map

GeoPoint centerMap = await controller.centerMap;

12.1) get geoPoint in the map

  • recuperate geoPoint of marker add it by user except static points
List<GeoPoint> geoPoints = await controller.geopoints;

13) get bounding box map

BoundingBox bounds = await controller.bounds;

14) Map Listener

Get GeoPoint from listener from controller directly (for more example: see home_example.dart )

a.1) single tap listener

controller.listenerMapSingleTapping.addListener(() {
      if (controller.listenerMapSingleTapping.value != null) {
        /// put you logic here
      }
    });

a.2) long tap listener

controller.listenerMapLongTapping.addListener(() {
      if (controller.listenerMapLongTapping.value != null) {
        /// put you logic here
      }
    });

a.3) region change listener

controller.listenerRegionIsChanging.addListener(() {
      if (controller.listenerRegionIsChanging.value != null) {
        /// put you logic here
      }
    });

15) Create Marker Programmatically

you can change marker icon by using attribute markerIcon the angle value should be between [0,2pi] set anchor of ther Marker

await controller.addMarker(GeoPoint,
      markerIcon:MarkerIcon,
      angle:pi/3,
      anchor:IconAnchor(anchor: Anchor.top,)
);

15.1) Update Marker

you can change the location,icon,angle,anchor of the specific marker

The old configuration of the Marker will be keep it the same if not specificied

await controller.changeLocationMarker(oldGeoPoint,newGeoPoint,MarkerIcon,angle,IconAnchor);

15.2) Change Icon Marker

You can change marker icon by using attribute markerIcon of existing Marker The GeoPoint/Marker should be exist

await controller.setMarkerIcon(GeoPoint,MarkerIcon);

15.3) Remove marker

 await controller.removeMarker(geoPoint);
  • PS : static position cannot be removed by this method

16) Draw road,recuperate instructions ,distance in km and duration in sec

you can add an middle position to pass your route through them change configuration of the road in runtime zoom into the region of the road change the type of the road that user want to use

 RoadInfo roadInfo = await controller.drawRoad( 
   GeoPoint(latitude: 47.35387, longitude: 8.43609),
   GeoPoint(latitude: 47.4371, longitude: 8.6136),
   roadType: RoadType.car,
   intersectPoint : [ GeoPoint(latitude: 47.4361, longitude: 8.6156), GeoPoint(latitude: 47.4481, longitude: 8.6266)]
   roadOption: RoadOption(
       roadWidth: 10,
       roadColor: Colors.blue,
       zoomInto: true,
   ),
);
 print("${roadInfo.distance}km");
 print("${roadInfo.duration}sec");
 print("${roadInfo.instructions}");

properties of RoadOption

Properties Description
roadColor (Color) required Field, change the default color of the route in runtime
roadWidth (double) change the road width, default value 5.0
roadBorderColor (Color?) set color of border polyline
roadBorderWidth (double?) set border width of polyline, if width null or 0,polyline will drawed without border
zoomInto (bool) change zoom level to make the all the road visible (default:true)

16.b) draw road manually

await controller.drawRoadManually(
        waysPoint,
        interestPointIcon: MarkerIcon(
          icon: Icon(
            Icons.location_history,
            color: Colors.black,
          ),
        ),
        interestPoints: [waysPoint[3],waysPoint[6]],
        zoomInto: true
)

17) Delete last road

 await controller.removeLastRoad();

18) draw multiple roads

final configs = [
      MultiRoadConfiguration(
        startPoint: GeoPoint(
          latitude: 47.4834379430,
          longitude: 8.4638911095,
        ),
        destinationPoint: GeoPoint(
          latitude: 47.4046149269,
          longitude: 8.5046595453,
        ),
      ),
      MultiRoadConfiguration(
          startPoint: GeoPoint(
            latitude: 47.4814981476,
            longitude: 8.5244329867,
          ),
          destinationPoint: GeoPoint(
            latitude: 47.3982152237,
            longitude: 8.4129691189,
          ),
          roadOptionConfiguration: MultiRoadOption(
            roadColor: Colors.orange,
          )),
      MultiRoadConfiguration(
        startPoint: GeoPoint(
          latitude: 47.4519015578,
          longitude: 8.4371175094,
        ),
        destinationPoint: GeoPoint(
          latitude: 47.4321999727,
          longitude: 8.5147623089,
        ),
      ),
    ];
    await controller.drawMultipleRoad(
      configs,
      commonRoadOption: MultiRoadOption(
        roadColor: Colors.red,
      ),
    );

19) delete all roads

 await controller.clearAllRoads();

20) Change static GeoPoint position

add new staticPoints with empty list of geoPoints (notice: if you add static point without marker,they will get default maker used by plugin)

change their position over time

change orientation of the static GeoPoint with GeoPointWithOrientation

 await controller.setStaticPosition(List<GeoPoint> geoPoints,String id );

21) Change/Add Marker old/new static GeoPoint position

add marker of new static point

change their marker of existing static geoPoint over time

 await controller.setMarkerOfStaticPoint(String id,MarkerIcon markerIcon );

22) change orientation of the map

 await controller.rotateMapCamera(degree);

23) Draw Shape in the map

  • Circle
 /// to draw
 await controller.drawCircle(CircleOSM(
              key: "circle0",
              centerPoint: GeoPoint(latitude: 47.4333594, longitude: 8.4680184),
              radius: 1200.0,
              color: Colors.red,
              borderColor:Colors.green,
              strokeWidth: 0.3,
            )
          );
 /// to remove Circle using Key
 await controller.removeCircle("circle0");

 /// to remove All Circle in the map 
 await controller.removeAllCircle();
  • Rect
 /// to draw
 await controller.drawRect(RectOSM(
              key: "rect",
              centerPoint: GeoPoint(latitude: 47.4333594, longitude: 8.4680184),
              distance: 1200.0,
              color: Colors.red.withOpacity(0.4),
              borderColor:Colors.green,
              strokeWidth: 0.3,
            ));
 /// to remove Rect using Key
 await controller.removeRect("rect");

 /// to remove All Rect in the map 
 await controller.removeAllRect();
  • remove all shapes in the map
 await controller.removeAllShapes();

Interfaces:

  • OSMMixinObserver :

contain listener methods to get event from native map view like when mapIsReady,mapRestored

you should add ths line controller.addObserver(this); in initState

override mapIsReady to implement your own logic after initialisation of the map

mapIsReady will replace listenerMapIsReady

Methods Description
mapIsReady (callback) Should be override this method, to get notified when map is ready to go or not
mapRestored (callback) Should be override this method, to get notified when map is restored you can also add you backup
onSingleTap (callback) Called when the user makes single click on map
onLongTap (callback) Called when the user makes long click on map
onRegionChanged (callback) Notified when map is change region (on moves)
onRoadTap (callback) Notified when user click on the polyline (road)
onLocationChanged (callback) Notified when user location changed

** example

class YourOwnStateWidget extends State<YourWidget> with OSMMixinObserver {

   //etc
  @override
  void initState() {
    super.initState();
    controller.addObserver(this);
  }
    @override
    Future<void> mapIsReady(bool isReady) async {
      if (isReady) {
        /// put you logic
      }
    }
  @override
  Future<void> mapRestored() async {
    super.mapRestored();
    /// TODO
  }
    @override
  void onSingleTap(GeoPoint position) {
    super.onSingleTap();
    /// TODO
  }

  @override
  void onLongTap(GeoPoint position) {
    super.onLongTap();
    /// TODO

  }

  @override
  void onRegionChanged(Region region) {
    super.onRegionChanged();
    /// TODO
  }

  @override
  void onRoadTap(RoadInfo road) {
    super.onRoadTap();
    /// TODO
  }
  @override
  void onLocationChanged(GeoPoint userLocation) {
    super.onLocationChanged();
    /// TODO
  }
}

OSMFlutter

Properties Description
mapIsLoading (Widget) show custom widget when the map finish initialization
osmOption (OSMOption) used to configure OSM Map such as zoom,road,userLocationMarker
onGeoPointClicked (callback) listener triggered when marker is clicked ,return current geoPoint of the marker
onLocationChanged (callback) it is fired when you activate tracking and user position has been changed
onMapMoved (callback) it is each the map moved user handler or navigate to another location using APIs
onMapIsReady (callback) listener trigger to get map is initialized or not

OSMOption

Properties Description
mapIsLoading (Widget) show custom widget when the map finish initialization
trackMyPosition enable tracking user position.
showZoomController show default zoom controller.
userLocationMarker change user marker or direction marker icon in tracking location
markerOption configure marker of osm map
zoomOption set configuration for zoom in the Map
roadConfiguration (RoadOption) set default color,width,borderColor,borderWdith for polylines
staticPoints List of Markers you want to show always ,should every marker have unique id
showContributorBadgeForOSM (bool) enable to show copyright widget of osm in the map
enableRotationByGesture (bool) enable to rotation gesture for map, default: false
showDefaultInfoWindow (bool) enable/disable default infoWindow of marker (default = false)
isPicker (bool) enable advanced picker from init of the map (default = false)

ZoomOption

Properties Description
stepZoom set step zoom to use in zoomIn()/zoomOut() (default 1)
initZoom set init zoom level in the map (default 10)
maxZoomLevel set maximum zoom level in the map (2 <= x <= 19)
minZoomLevel set minimum zoom level in the map (2 <= x <= 19 )

Custom Controller

To create your own MapController to need to extends from BaseMapController, if you want to make a custom initialization to need to call init() and put your code after super.init()

  • example
class CustomMapController extends BaseMapController {

  @override
  void dispose() {
    /// TODO put you logic here
    super.dispose();
  }

  @override
  void init() {
    super.init();
    /// TODO put you logic here
  }
}

STATIC METHODS:

1) Calculate distance between 2 geoPoint position

 double distanceEnMetres = await distance2point(GeoPoint(longitude: 36.84612143139903,latitude: 11.099388684927824,),
        GeoPoint( longitude: 36.8388023164018, latitude: 11.096959785428027, ),);

2) Get search Suggestion of text

you should know that i'm using public api, don't make lot of request

    List<SearchInfo> suggestions = await addressSuggestion("address");

show dialog picker

simple dialog location picker to selected user location

GeoPoint p = await showSimplePickerLocation(
                      context: context,
                      isDismissible: true,
                      title: "Title dialog",
                      textConfirmPicker: "pick",
                      initCurrentUserPosition: true,
                    )

CustomLocationPicker

customizable widget to build search location

you should use PickerMapController as controller for the widget see example : search widget

Properties of CustomLocationPicker

Properties Description
controller (PickerMapController) controller of the widget
appBarPicker (AppBar) appbar for the widget
topWidgetPicker (Widget?) widget will be show on top of osm map,for example to show address suggestion
bottomWidgetPicker (Widget?) widget will be show at bottom of screen for example to show more details about selected location or more action

NOTICE:

For now the map working for android,iOS , web will be available soon

If you get ssl certfiction exception,use can use http by following instruction below

If you want to use http in Android PIE or above :

  • enable useSecureURL and add android:usesCleartextTraffic="true" in your manifest like example below :

    • <application ... android:usesCleartextTraffic="true">

if you faced build error in fresh project you need to follow those instruction #40

1) remove flutter_osm_plugin from pubspec, after that pub get
2) open android module in android studio ( right click in name of project -> flutter-> open android module in android studio)
3) update gradle version to 4.1.1 ( IDE will show popup to make update)
4) update kotlin version to 1.4.21 & re-build the project
5) re-add flutter_osm_plugin in pubspec , pub get ( or flutter clean & pub get )

Before you publish your application using this library, you should take care about copyright of openStreetMap Data, that's why i add CopyrightOSMWidget see example and this issue #101

MIT LICENCE

osm_flutter's People

Contributors

aadarshadhakalg avatar amaran-futura avatar arbyazra123 avatar derklaro avatar jesussmile avatar jobijoba avatar liodali avatar marlonjd avatar miladebadi avatar rockerer avatar simonprins avatar vargab95 avatar xyzbilal 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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

osm_flutter's Issues

Null check operator used on a null value

Hi! Just started to use your newer plugin flutter_osm_plugin: ^0.7.8, with the same code structure, that didn't give any errors, I get
Null check operator used on a null value
I updated my usage of widget OSMFlutter(....) to include Road and markerIcon as per your setup, The error is on class OSMFlutter on line 215 (widget.markerOption!.defaultMarker != null)) I suppose it is because of using null safety? If I remove the line it works okay, Any workaround? I don't want to mess with your core files. I don't use null safety and have very little idea about it. probably my error is because Widget.markerOption hasn't been initialized?

add bicycle and foot for drawRoad

osrm support for car,bicycles and foot for drawing road
i will add two other support in osm to draw road
it will be available for (android / ios)

Reverse GeoCoding

It will also be helpful if we get the address of the location (not only GeoPoint) if we select the marker while picking the location. I know that it can be achieved without any service and some Packages like GeoCoding have the feature to get the address from Platform's own services. But the users of your package will be mostly from the countries like China where Google Play Services do not work

OSRMRoadManager::getRoad: error code=InvalidUrl

Hey! sorry to bother you again, I think there is an error with the URL after I updated my plugin to the recent one flutter_osm_plugin: ^0.7.8+3 . However it works correctly with the example project I download from Github .
The output in Debug console

OSRMRoadManager::getRoad: error code=InvalidUrl

OSRMRoadManager.getRoads:https://router.project-osrm.org/route/v1/driving/routed-car/route/v1/driving/85.3481299537,27.7013308999;85.3459259442,27.7013987508?alternatives=false&overview=full&steps=true

OpenStreetMap Copyright and License

According to their Copyright and License page (https://www.openstreetmap.org/copyright), I think by default the copyright should be added to this widget according to their specification "For a browsable electronic map, the credit should appear in the corner of the map". I'm no lawyer, but I think this repo may be breaking their copyright and license rules at least when it comes to the demo and snippets.

In case something changes with their copyright and licensing, it may be a good idea to add an option to opt-out of the credit.

Using changeLocation resets the zoom

I'm using 0.7.9+3. Whenever i call changeLocation the zoom of the map gets reset to maximally zoomed out. Also it seems that the markers from previous changeLocation calls don't get removed, is that intended behaviour?

Ugly world map displayed during map initialization

During the initialization of OSMFlutter, a strange empty world map is represented before the final map and current location/position is beeing displayed to the user. Would be great if there could be a callback method or similar called if the map is completely loaded, that would help to implement a progress loading bar.

Screenshot 2021-06-22 at 21 34 43

[Feature Reuqest] Offline maps

Hi,

I would like to use this plugin on my app, but we would like to have the possibility to have offline maps.

I'm not sure of how difficult is to implement this, maybe we can help on that if you have an idea of how to do it...

Thanks in advance

Errors in Code Example

The code example given in the README.md has some small mistakes:

 OSMFlutter( 
        controler:mapController,
        currentLocation: false,
        road: Road(

where controler:mapController has to be changed to controller:mapController.

Furthermore the constructor of OSMFlutter doesn't have an entry for initPosition, which seems to be moved to MapController, so the line should be removed

support dark mode in osm

  • add attribute to activate dark mode in osm map
  • create function to switch between light mode and dark mode

RenderBox was not laid out

Hey. Great project!

I have implemented a very simple OSMFlutter widget, using the code below

  MapController mapController = MapController(
    initMapWithUserPosition: true,
  );
      body: Container(
        child: Stack(children: <Widget>[
          OSMFlutter(
            controller: mapController,
            trackMyPosition: true,
            useSecureURL: false,
            showDefaultInfoWindow: false,
            defaultZoom: 3.0,
          ),
        ]),
      )

I keep getting the following error:

RenderBox was not laid out: RenderStack#1b4a0 relayoutBoundary=up3 NEEDS-PAINT
'package:flutter/src/rendering/box.dart':
Failed assertion: line 1940 pos 12: 'hasSize'

When i from portrait to landscape or vice versa i get the following error:

======== Exception caught by rendering library =====================================================
The following assertion was thrown during performLayout():
'package:flutter/src/rendering/object.dart': Failed assertion: line 1711 pos 12: '!_debugDoingThisLayout': is not true.

Either the assertion indicates an error in the framework itself, or we should provide substantially more information in this error message to help you determine and fix the underlying cause.
In either case, please report this assertion by filing a bug on GitHub:
https://github.com/flutter/flutter/issues/new?template=2_bug.md

The relevant error-causing widget was:
OSMFlutter file:///C:/flutter_projects/mobile-app/lib/RobotPage.dart:93:11
When the exception was thrown, this was the stack:
#2 RenderObject.layout (package:flutter/src/rendering/object.dart:1711:12)
#3 RenderStack.layoutPositionedChild (package:flutter/src/rendering/stack.dart:497:11)
#4 RenderStack.performLayout (package:flutter/src/rendering/stack.dart:610:30)
#5 RenderObject.layout (package:flutter/src/rendering/object.dart:1784:7)
#6 ChildLayoutHelper.layoutChild (package:flutter/src/rendering/layout_helper.dart:54:11)
...
The following RenderObject was being processed when the exception was fired: RenderStack#1ee0e relayoutBoundary=up2 NEEDS-PAINT
... needs compositing
... parentData: not positioned; offset=Offset(0.0, 0.0) (can use size)
... constraints: BoxConstraints(0.0<=w<=384.0, 0.0<=h<=739.7)
... size: Size(384.0, 739.7)
... alignment: AlignmentDirectional.topStart
... textDirection: ltr
... fit: loose
... clipBehavior: none
RenderObject: RenderStack#1ee0e relayoutBoundary=up2 NEEDS-PAINT
needs compositing
parentData: not positioned; offset=Offset(0.0, 0.0) (can use size)
constraints: BoxConstraints(0.0<=w<=384.0, 0.0<=h<=739.7)
size: Size(384.0, 739.7)
alignment: AlignmentDirectional.topStart
textDirection: ltr
fit: loose
clipBehavior: none
... child 1: RenderStack#76d10 relayoutBoundary=up3
... parentData: top=-100.0; offset=Offset(0.0, 0.0) (can use size)
... constraints: BoxConstraints(unconstrained)
... size: MISSING
... alignment: AlignmentDirectional.topStart
... textDirection: ltr
... fit: loose
... child 2: RenderSemanticsAnnotations#590eb relayoutBoundary=up3 NEEDS-PAINT
... needs compositing
... parentData: not positioned; offset=Offset(0.0, 0.0) (can use size)
... constraints: BoxConstraints(0.0<=w<=384.0, 0.0<=h<=739.7)
... semantics node: SemanticsNode#17
... Rect.fromLTRB(0.0, 96.2, 813.2, 368.0)
... flags: isFocusable
... size: Size(384.0, 739.7)
... child: RenderAndroidView#8cc97 NEEDS-PAINT
... needs compositing
... parentData: (can use size)
... constraints: BoxConstraints(0.0<=w<=384.0, 0.0<=h<=739.7)
... layer: OffsetLayer#f305b DETACHED
... engine layer: OffsetEngineLayer#2212b
... offset: Offset(0.0, 96.2)
... semantics node: SemanticsNode#18
... Rect.fromLTRB(0.0, 0.0, 813.2, 271.8)
... platformViewId: 0
... semantic boundary
... size: Size(384.0, 739.7)

D/OsmDroid(18671): TileLoader failed to load tile due to mWriter being null (map shutdown?)
I/chatty (18671): uid=10404(com.example.flutter_app) GarbageCollecto identical 3 lines

The second error, results in no connection to the map repository, and i thus have an only grey screen.

I suspect these errors to be connected, and i have tried wrapping the OSM widget in an expanded widget and a flexible widget, but the problem persists.

My current solution is to restrict the application to portrait mode, which means i never lose the connection to the map repository, but this is not a satisfactory solution as i would like to allow landscape mode.

Does anyone have a solution, or tried similar?

UPDATE:
This does not happen, when I use the simple OSMFlutter from examples. I don't see the difference though. I am however still not able to rotate the screen, and still have the map.

I suspect the following error is what does it:
V/ViewRootImpl( 6646): The specified message queue synchronization barrier token has not been posted or has already been removed

[discussion] suggestion of real world example

I planning to start creating new examples that illustrate real world applications
of course without turn by turn navigation 😅 because it's still not available
my idea is to create citymapper example using the plugin
anyone is free to give me idea to implement

[discussion] select position in map

selection in plugin we can by this code

var geoPoint = await controller.selectPosition();

the problem with that is we freez the all other feature until user tap on screen
so i want to discussion is that fine because i planned to change that behaviour
and make plugin accept longPress to add new marker
for example

controller.listToLongPress((geoPoint){
 // some code

});
controller.selectPosition();

How to Update the route on Users location change

Hi,

Is there any method or anyway by which we can update the route depending on the location of the user?

I am using the below code to set a route from the user's current location to a specific cordinates, but when the user changes location the route doesn't update.
Is there any way I can update the route when the user changes location.

The Code

await controller.enableTracking();
GeoPoint geoPoint = await controller.myLocation();

print (geoPoint.latitude);
print(geoPoint.longitude);

RoadInfo roadInfo = await controller.drawRoad(
GeoPoint(latitude: geoPoint.latitude, longitude: geoPoint.longitude),
GeoPoint(latitude: 24.913608364530518, longitude: 67.03123161285491),
interestPoints : [GeoPoint(latitude: 24.913608364530518, longitude: 67.03123161285491)],
   roadOption: RoadOption(
   roadWidth: 20.0,
   roadColor: Colors.red,
showMarkerOfPOI: true
 ),
);
   print("${roadInfo.distance}km");
   print("${roadInfo.duration}sec");


I've also tried using

await controller.enableTracking().then((value) => {
    GeoPoint geoPoint = await controller.myLocation();
      ...
    });

But it doesn't work.

Can someone help me out on this issue?

instruction of route

when drawRoad we can get instruction of route
in this issue i will add get instruction of each route with information that already provided duration & distance

improve readabilty of code

in this issue, I will try to improve readablity of code, integrate GetX package to remove the usage of globalkey
and to separate the logic from UI

advanced selection

in this issue i will try to add assisted picker to select sepecific location

Null pointer Exception while drawing a road between two points

I am trying to draw roads between two GeoPoint without using interestPoints, I keep running into this error

E/MethodChannel#plugins.dali.hamza/osmview_0(20152): java.lang.NullPointerException: null cannot be cast to non-null type kotlin.collections.List<kotlin.collections.HashMap<kotlin.String, kotlin.Double> /* = java.util.HashMap<kotlin.String, kotlin.Double> */>

The way I am trying to implement is by removing the interestPoints totally, I suppose it is a required field how can I get past it ?

`
IconButton(
onPressed: () async {
try {
await controller.removeLastRoad();

            //selection geoPoint
            GeoPoint point = await controller.selectPosition(
                icon: MarkerIcon(
              icon: Icon(
                Icons.location_history,
                color: Colors.amber,
                size: 48,
              ),
            ));
           // GeoPoint pointM1 = await controller.selectPosition();
           // GeoPoint pointM2 = await controller.selectPosition(
               // imageURL:
                 //   "https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/back/1.png");
            GeoPoint point2 = await controller.selectPosition();
            
            RoadInfo roadInformation = await controller.drawRoad(
                point, point2,
               // interestPoints: [pointM1, pointM2],
                roadOption: RoadOption(
                    roadWidth: 10.0,
                    roadColor: Colors.blue,
                    showMarkerOfPOI: false));
            print(
                "duration:${Duration(seconds: roadInformation.duration!.toInt()).inMinutes}");
            print("distance:${roadInformation.distance}Km");
          } on RoadException catch (e) {
            print (e);
            ScaffoldMessenger.of(context).showSnackBar(
              SnackBar(
                content: Text(
                  "${e.errorMessage()}",
                ),
              ),
            );
          }
        },
        icon: Icon(Icons.map),
      ),

`

It would be nice if you could rename interestPoint to intersectPoint ? Makes more sense but it's up to you.

Unable to run the application `Execution failed for task ':flutter_osm_plugin:kaptGenerateStubsDebugKotlin'.`

Hi,
I am unable to run the application after adding flutter_osm_plugin: ^0.7.5+2 in to pubspec.yaml file. I also tried with fresh application. I am trying to run it on mobile

TO REPRODUCE

  • Create new project and add flutter_osm_plugin: ^0.7.5+2 in pubspec.yaml file and run the application.
Launching lib\main.dart on Mi 9T in debug mode...
Parameter format not correct -
Note: D:\Flutter\flutter\.pub-cache\hosted\pub.dartlang.org\location-4.1.1\android\src\main\java\com\lyokone\location\FlutterLocation.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
e: D:\Flutter\flutter\.pub-cache\hosted\pub.dartlang.org\flutter_osm_plugin-0.7.5+2\android\src\main\kotlin\hamza\dali\flutter_osm_plugin\FlutterInfoWindow.kt: (42, 56): Expecting an argument
e: D:\Flutter\flutter\.pub-cache\hosted\pub.dartlang.org\flutter_osm_plugin-0.7.5+2\android\src\main\kotlin\hamza\dali\flutter_osm_plugin\FlutterOsmPlugin.kt: (60, 53): Expecting an argument
e: D:\Flutter\flutter\.pub-cache\hosted\pub.dartlang.org\flutter_osm_plugin-0.7.5+2\android\src\main\kotlin\hamza\dali\flutter_osm_plugin\FlutterOsmPlugin.kt: (61, 23): Expecting an argument
e: D:\Flutter\flutter\.pub-cache\hosted\pub.dartlang.org\flutter_osm_plugin-0.7.5+2\android\src\main\kotlin\hamza\dali\flutter_osm_plugin\FlutterOsmPlugin.kt: (91, 34): Expecting an argument
e: D:\Flutter\flutter\.pub-cache\hosted\pub.dartlang.org\flutter_osm_plugin-0.7.5+2\android\src\main\kotlin\hamza\dali\flutter_osm_plugin\FlutterOsmPlugin.kt: (92, 19): Expecting an argument
e: D:\Flutter\flutter\.pub-cache\hosted\pub.dartlang.org\flutter_osm_plugin-0.7.5+2\android\src\main\kotlin\hamza\dali\flutter_osm_plugin\FlutterOsmView.kt: (95, 31): Expecting a parameter declaration
e: D:\Flutter\flutter\.pub-cache\hosted\pub.dartlang.org\flutter_osm_plugin-0.7.5+2\android\src\main\kotlin\hamza\dali\flutter_osm_plugin\FlutterOsmView.kt: (926, 52): Expecting an argument
e: D:\Flutter\flutter\.pub-cache\hosted\pub.dartlang.org\flutter_osm_plugin-0.7.5+2\android\src\main\kotlin\hamza\dali\flutter_osm_plugin\FlutterRoad.kt: (12, 38): Expecting a parameter declaration
e: D:\Flutter\flutter\.pub-cache\hosted\pub.dartlang.org\flutter_osm_plugin-0.7.5+2\android\src\main\kotlin\hamza\dali\flutter_osm_plugin\OsmFactory.kt: (18, 41): Expecting a parameter declaration
e: D:\Flutter\flutter\.pub-cache\hosted\pub.dartlang.org\flutter_osm_plugin-0.7.5+2\android\src\main\kotlin\hamza\dali\flutter_osm_plugin\OsmFactory.kt: (23, 24): Expecting a parameter declaration
e: D:\Flutter\flutter\.pub-cache\hosted\pub.dartlang.org\flutter_osm_plugin-0.7.5+2\android\src\main\kotlin\hamza\dali\flutter_osm_plugin\OsmFactory.kt: (31, 27): Expecting an argument
e: D:\Flutter\flutter\.pub-cache\hosted\pub.dartlang.org\flutter_osm_plugin-0.7.5+2\android\src\main\kotlin\hamza\dali\flutter_osm_plugin\network\ApiClient.kt: (17, 39): Expecting a parameter declaration
e: D:\Flutter\flutter\.pub-cache\hosted\pub.dartlang.org\flutter_osm_plugin-0.7.5+2\android\src\main\kotlin\hamza\dali\flutter_osm_plugin\utilities\FlutterPickerViewOverlay.kt: (10, 34): Expecting a parameter declaration

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':flutter_osm_plugin:kaptGenerateStubsDebugKotlin'.
> Compilation error. See log for more details

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 6m 0s
Exception: Gradle task assembleDebug failed with exit code 1
Exited (sigterm)

flutter doctor -v

Microsoft Windows [Version 10.0.19042.985]
(c) Microsoft Corporation. All rights reserved.

C:\Users\Usama Karim>flutter doctor -v
[√] Flutter (Channel stable, 2.0.6, on Microsoft Windows [Version 10.0.19042.985], locale en-PK)
    • Flutter version 2.0.6 at D:\Flutter\flutter
    • Framework revision 1d9032c7e1 (2 weeks ago), 2021-04-29 17:37:58 -0700
    • Engine revision 05e680e202
    • Dart version 2.12.3

[√] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
    • Android SDK at D:\Flutter\Android
    • Platform android-30, build-tools 30.0.3
    • ANDROID_SDK_ROOT = D:\Flutter\Android
    • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
    • All Android licenses accepted.

[√] Chrome - develop for the web
    • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe

[√] Android Studio (version 4.1.0)
    • Android Studio at C:\Program Files\Android\Android Studio
    • Flutter plugin can be installed from:
       https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
       https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)

[√] VS Code (version 1.56.2)
    • VS Code at C:\Users\Usama Karim\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension version 3.22.0

[√] Connected device (3 available)
    • Mi 9T (mobile) • ca0d513e • android-arm64  • Android 10 (API 29)
    • Chrome (web)   • chrome   • web-javascript • Google Chrome 90.0.4430.212
    • Edge (web)     • edge     • web-javascript • Microsoft Edge 89.0.774.75

• No issues found!

Persisting currentLocation

Hi,
I am trying to show a GeoPoint as initPosition, but the OSMFlutter widget persists showing user's location when loading.
(Actually it seems to show the GeoPoint position for a few ms, then going directly to user's location)
A related problem is the app asking for location permission, which I prefer to keep off for now.

currentLocation and trackMyPosition are both set to false.

I am showing the widget in the following way, invoked as a BottomNavigationBarItem:

Widget getContacts() {
    GlobalKey<OSMFlutterState> osmKey = GlobalKey<OSMFlutterState>();

    var col = new Column(
      children: <Widget>[
        Expanded(
            child: OSMFlutter(
          key: osmKey,
          currentLocation: false,
          road: Road(
            startIcon: MarkerIcon(
              icon: Icon(
                Icons.person,
                size: 64,
                color: Colors.brown,
              ),
            ),
            roadColor: Colors.red,
          ),
          markerIcon: MarkerIcon(
            icon: Icon(
              Icons.assistant_photo,
              color: Colors.blue,
              size: 80,
            ),
          ),
          initPosition: GeoPoint(latitude: 42.151753, longitude: 24.769730),
          showZoomController: true,
          trackMyPosition: false,
        )),
        IconButton(
          icon: Icon(Icons.ac_unit),
          onPressed: () {
//            goToLocation();
            MapsLauncher.launchCoordinates(42.151753, 24.769730);
          },
        )
      ],
    );

//    osmKey.currentState.changeLocation(
//        GeoPoint(latitude: 42.151753, longitude: 24.769730));

    return col;
  }
...
environment:
  sdk: ">=2.7.0 <3.0.0"

dependencies:
  flutter:
    sdk: flutter

  maps_launcher: ^1.2.0
  flutter_osm_plugin: ^0.3.6+3
...

The project is quite small, you can try it yourself:
batyanko/table-tennis-club@a5b227b

Tested on Galaxy S7 and the API 30 Emulator (w/GooglePlay)

Note: I am new to Flutter, might have done various things wrong. Let me know.

migration from java to kotlin

I will move all native code in Android section from java to kotlin ,also i will remove all deprecation api and will try to use Flow API

Build failed errors

Hi, I followed the steps for the plugin, updated Kotlin and Flutter, However, I run into errors. Any help please, sorry if its a beginner question.
` e: C:\Users\pannam\Desktop\flutter_windows_2.0.6-stable\flutter.pub-cache\hosted\pub.dartlang.org\flutter_osm_plugin-0.7.6+1\android\src\main\kotlin\hamza\dali\flutter_osm_plugin\FlutterInfoWindow.kt: (42, 56): Expecting an argument
e: C:\Users\pannam\Desktop\flutter_windows_2.0.6-stable\flutter.pub-cache\hosted\pub.dartlang.org\flutter_osm_plugin-0.7.6+1\android\src\main\kotlin\hamza\dali\flutter_osm_plugin\FlutterOsmPlugin.kt: (60, 53): Expecting an argument
e: C:\Users\pannam\Desktop\flutter_windows_2.0.6-stable\flutter.pub-cache\hosted\pub.dartlang.org\flutter_osm_plugin-0.7.6+1\android\src\main\kotlin\hamza\dali\flutter_osm_plugin\FlutterOsmPlugin.kt: (61, 23): Expecting an argument
e: C:\Users\pannam\Desktop\flutter_windows_2.0.6-stable\flutter.pub-cache\hosted\pub.dartlang.org\flutter_osm_plugin-0.7.6+1\android\src\main\kotlin\hamza\dali\flutter_osm_plugin\FlutterOsmPlugin.kt: (91, 34): Expecting an argument
e: C:\Users\pannam\Desktop\flutter_windows_2.0.6-stable\flutter.pub-cache\hosted\pub.dartlang.org\flutter_osm_plugin-0.7.6+1\android\src\main\kotlin\hamza\dali\flutter_osm_plugin\FlutterOsmPlugin.kt: (92, 19): Expecting an argument
e: C:\Users\pannam\Desktop\flutter_windows_2.0.6-stable\flutter.pub-cache\hosted\pub.dartlang.org\flutter_osm_plugin-0.7.6+1\android\src\main\kotlin\hamza\dali\flutter_osm_plugin\FlutterOsmView.kt: (92, 31): Expecting a parameter declaration
e: C:\Users\pannam\Desktop\flutter_windows_2.0.6-stable\flutter.pub-cache\hosted\pub.dartlang.org\flutter_osm_plugin-0.7.6+1\android\src\main\kotlin\hamza\dali\flutter_osm_plugin\FlutterOsmView.kt: (418, 41): Expecting an argument
e: C:\Users\pannam\Desktop\flutter_windows_2.0.6-stable\flutter.pub-cache\hosted\pub.dartlang.org\flutter_osm_plugin-0.7.6+1\android\src\main\kotlin\hamza\dali\flutter_osm_plugin\FlutterOsmView.kt: (946, 52): Expecting an argument
e: C:\Users\pannam\Desktop\flutter_windows_2.0.6-stable\flutter.pub-cache\hosted\pub.dartlang.org\flutter_osm_plugin-0.7.6+1\android\src\main\kotlin\hamza\dali\flutter_osm_plugin\FlutterRoad.kt: (12, 38): Expecting a parameter declaration
e: C:\Users\pannam\Desktop\flutter_windows_2.0.6-stable\flutter.pub-cache\hosted\pub.dartlang.org\flutter_osm_plugin-0.7.6+1\android\src\main\kotlin\hamza\dali\flutter_osm_plugin\OsmFactory.kt: (18, 41): Expecting a parameter declaration
e: C:\Users\pannam\Desktop\flutter_windows_2.0.6-stable\flutter.pub-cache\hosted\pub.dartlang.org\flutter_osm_plugin-0.7.6+1\android\src\main\kotlin\hamza\dali\flutter_osm_plugin\OsmFactory.kt: (23, 24): Expecting a parameter declaration
e: C:\Users\pannam\Desktop\flutter_windows_2.0.6-stable\flutter.pub-cache\hosted\pub.dartlang.org\flutter_osm_plugin-0.7.6+1\android\src\main\kotlin\hamza\dali\flutter_osm_plugin\OsmFactory.kt: (31, 27): Expecting an argument
e: C:\Users\pannam\Desktop\flutter_windows_2.0.6-stable\flutter.pub-cache\hosted\pub.dartlang.org\flutter_osm_plugin-0.7.6+1\android\src\main\kotlin\hamza\dali\flutter_osm_plugin\network\ApiClient.kt: (17, 39): Expecting a parameter declaration
e: C:\Users\pannam\Desktop\flutter_windows_2.0.6-stable\flutter.pub-cache\hosted\pub.dartlang.org\flutter_osm_plugin-0.7.6+1\android\src\main\kotlin\hamza\dali\flutter_osm_plugin\utilities\FlutterPickerViewOverlay.kt: (11, 47): Expecting a parameter declaration

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':flutter_osm_plugin:kaptGenerateStubsDebugKotlin'.

Compilation error. See log for more details

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

  • Get more help at https://help.gradle.org

BUILD FAILED in 15s
Exception: Gradle task assembleDebug failed with exit code 1
`

null object reference

This generally occurs when running it thru an IDE, either to debug or running without debugging. Null Object Reference
Impact: The Map doesn't load, Could you please check it

Debug Console

[ERROR:flutter/lib/ui/ui_dart_state.cc(186)] Unhandled Exception: PlatformException(error, Attempt to invoke virtual method 'org.osmdroid.views.MapViewRepository org.osmdroid.views.MapView.getRepository()' on a null object reference, null, java.lang.NullPointerException: Attempt to invoke virtual method 'org.osmdroid.views.MapViewRepository org.osmdroid.views.MapView.getRepository()' on a null object reference

Files causing the error


E/flutter (28434): )
E/flutter (28434): #0      StandardMethodCodec.decodeEnvelope
package:flutter/…/services/message_codecs.dart:581
E/flutter (28434): #1      MethodChannel._invokeMethod
package:flutter/…/services/platform_channel.dart:158
E/flutter (28434): <asynchronous suspension>
E/flutter (28434): #2      MethodChannelOSM.addPosition
package:flutter_osm_plugin/…/channel/osm_method_channel.dart:156
E/flutter (28434): <asynchronous suspension>
E/flutter (28434): #3      OSMController.changeLocation
package:flutter_osm_plugin/…/controller/osm_controller.dart:169
E/flutter (28434): <asynchronous suspension>
E/flutter (28434): #4      OSMController.initMap
package:flutter_osm_plugin/…/controller/osm_controller.dart:93
E/flutter (28434): <asynchronous suspension>
E/flutter (28434): #5      BaseMapController.init.<anonymous closure>
package:flutter_osm_plugin/…/controller/base_map_controller.dart:39
E/flutter (28434): <asynchronous suspension>

Missing feature to define multiple waypoints and draw road

Would it possible to draw roads (add/remove waypoints) with tapping directly inside the map? Is there maybe at least a listener for tapping/click event on the map?
This would be a great feature because I need to draw routes by tapping/clicking on the map and finally drawing a road based on all the defined waypoints.

delay in get picklocation

when i use below code for select a postion not work correctly.

GeoPoint point= await osmKey.currentState.selectPosition();
print(point);

null safety migration

  • migrate plugin to null safety feature
  • remove unsupported dependencies
  • change dependencies location_permission to location

Reset zoom snapping to default location

I've enabled the currentUserLocation and the issue is that irrespective of my numerous attempts to zoom (double tap inclusive), the zoom resets to default as was launched. Neither zoom-in, nor zoom-out works. Panning area works although but the issue is with zoom.

This issue only happens with CurrentUserLocation enabled. Possibly re-snaps zoom to given userLocation post every update or zoom/pan.

Build failure for fresh project

Howdy mate! Love your awesome wrapper for open-source map implementation.

The build failed with following stacktrace. No idea of the fix! It is a fresh project created for flutter with latest version (both flutter and your plugin).

Launching lib\main.dart on Mi Max 2 in debug mode...
lib\main.dart:1

FAILURE: Build failed with an exception.

* Where:
Build file 'C:\Users\mhetr\AppData\Local\Pub\Cache\hosted\pub.dartlang.org\flutter_osm_plugin-0.4.7+3\android\build.gradle' line: 47

* What went wrong:
A problem occurred evaluating project ':flutter_osm_plugin'.
> Could not find method buildFeatures() for arguments [build_8hixj53buk134vkzq4463b2ue$_run_closure2$_closure9@1de153b1] on object of type com.android.build.gradle.LibraryExtension.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

Zoom to bounding box and restrict

Is this feature available perhaps? I wish to zoom to a country bounding box and not let the user zoom out. Android library has

map.zoomToBoundingBox(getCountryBoundingBox(), false)
map.setScrollableAreaLimitDouble(getCountryBoundingBox())

Perhaps available in this flutter lib?

Minor issue with naming convention

HI! Nothing major but as your class GeoPoint calls out for GeoPoint =GeoPoint(latitude: latitude, longitude: longitude) but the return string in your GeoPoint class gives longitude first than latitude which is a little confusing return 'GeoPoint{longitude: $longitude, latitude: $latitude}'; Perhaps we could keep it to similar naming convention as in navigation it will give 0km and 0 sec.

Have problems with building

Launching lib/main.dart on Android SDK built for x86 in debug mode...
Running Gradle task 'assembleDebug'...
e: /home/duvewo/snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_osm_plugin-0.6.6/android/src/main/kotlin/hamza/dali/flutter_osm_plugin/FlutterOsmView.kt: (747, 26): Type mismatch: inferred type is String? but String was expected

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':flutter_osm_plugin:compileDebugKotlin'.
> Compilation error. See log for more details

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 7s
Exception: Gradle task assembleDebug failed with exit code 1

gradle --version


------------------------------------------------------------
Gradle 4.4.1
------------------------------------------------------------

Build time:   2012-12-21 00:00:00 UTC
Revision:     none

Groovy:       2.4.20
Ant:          Apache Ant(TM) version 1.10.8 compiled on January 8 1970
JVM:          1.8.0_282 (Private Build 25.282-b08)
OS:           Linux 5.8.0-44-generic amd64

Am I missing something?

Can't save the state of the map after searching for address

I am trying to use AutomaticKeepAliveClientMixin to save the state of the Map when I draw features like road etc . For the most part it seems to be working but as soon as I go to the search place and search for a location, the map will reload. Can you explain this behaviour and how can I get around it? I tried with just populating the search result and not selecting it, still the map reloads.

class _MainExampleState extends State<MainExample> with AutomaticKeepAliveClientMixin<MainExample> {

bool get wantKeepAlive => true;
 @override
 
 Widget build(BuildContext context) {
   super.build(context);
   return Scaffold( 

build package problem

I tried to build my project after added the package, and I have received this issue :

FAILURE: Build failed with an exception.                                
                                                                        
* Where:                                                                
Build file '/home/smart/snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_osm_plugin-0.4.4+3/android/build.gradle' line: 33
                                                                        
* What went wrong:                                                      
A problem occurred evaluating project ':flutter_osm_plugin'.            
> No signature of method: build_2me5ksikswva2ip8eqqrud8zj.android() is applicable for argument types: (build_2me5ksikswva2ip8eqqrud8zj$_run_closure2) values: [build_2me5ksikswva2ip8eqqrud8zj$_run_closure2@670662f8]
                                                                        
* Try:                                                                  
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
                                                                        
* Get more help at https://help.gradle.org                              
                                                                        
BUILD FAILED in 8s  

do you have any idea to resolve it ?
thanks in advance , good Job and best continuation Weld bledi ;) .

java.lang.IndexOutOfBoundsException

java.lang.IndexOutOfBoundsException: Index: 262, Size: 262
E/AndroidRuntime(16855): at java.util.ArrayList.get(ArrayList.java:437)
E/AndroidRuntime(16855): at hamza.dali.flutter_osm_plugin.FlutterRoad.drawEndPoint(FlutterRoad.java:33)
E/AndroidRuntime(16855): at hamza.dali.flutter_osm_plugin.FlutterRoad.drawRoad(FlutterRoad.java:49)
E/AndroidRuntime(16855): at hamza.dali.flutter_osm_plugin.FlutterOsmView$4.onPostExecute(FlutterOsmView.java:493)
E/AndroidRuntime(16855): at hamza.dali.flutter_osm_plugin.FlutterOsmView$4.onPostExecute(FlutterOsmView.java:467)
E/AndroidRuntime(16855): at android.os.AsyncTask.finish(AsyncTask.java:695)
E/AndroidRuntime(16855): at android.os.AsyncTask.access$600(AsyncTask.java:180)
E/AndroidRuntime(16855): at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:712)
E/AndroidRuntime(16855): at android.os.Handler.dispatchMessage(Handler.java:106)
E/AndroidRuntime(16855): at android.os.Looper.loop(Looper.java:214)
E/AndroidRuntime(16855): at android.app.ActivityThread.main(ActivityThread.java:7091)
E/AndroidRuntime(16855): at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(16855): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494)
E/AndroidRuntime(16855): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:975)

Simply add map after install dependency getting compilation error

e: C:\Users\prabhunt\Downloads\flutter_windows_2.0.2-stable\flutter.pub-cache\hosted\pub.dartlang.org\flutter_osm_plugin-0.6.7+3\android\src\main\kotlin\hamza\dali\flutter_osm_plugin\FlutterInfoWindow.kt: (42, 56): Expecting an argument
e: C:\Users\prabhunt\Downloads\flutter_windows_2.0.2-stable\flutter.pub-cache\hosted\pub.dartlang.org\flutter_osm_plugin-0.6.7+3\android\src\main\kotlin\hamza\dali\flutter_osm_plugin\FlutterOsmPlugin.kt: (92, 34): Expecting an argument
e: C:\Users\prabhunt\Downloads\flutter_windows_2.0.2-stable\flutter.pub-cache\hosted\pub.dartlang.org\flutter_osm_plugin-0.6.7+3\android\src\main\kotlin\hamza\dali\flutter_osm_plugin\FlutterOsmPlugin.kt: (93, 19): Expecting an argument
e: C:\Users\prabhunt\Downloads\flutter_windows_2.0.2-stable\flutter.pub-cache\hosted\pub.dartlang.org\flutter_osm_plugin-0.6.7+3\android\src\main\kotlin\hamza\dali\flutter_osm_plugin\FlutterOsmView.kt: (89, 31): Expecting a parameter declaration
e: C:\Users\prabhunt\Downloads\flutter_windows_2.0.2-stable\flutter.pub-cache\hosted\pub.dartlang.org\flutter_osm_plugin-0.6.7+3\android\src\main\kotlin\hamza\dali\flutter_osm_plugin\FlutterRoad.kt: (12, 38): Expecting a parameter declaration
e: C:\Users\prabhunt\Downloads\flutter_windows_2.0.2-stable\flutter.pub-cache\hosted\pub.dartlang.org\flutter_osm_plugin-0.6.7+3\android\src\main\kotlin\hamza\dali\flutter_osm_plugin\OsmFactory.kt: (19, 57): Expecting a parameter declaration
e: C:\Users\prabhunt\Downloads\flutter_windows_2.0.2-stable\flutter.pub-cache\hosted\pub.dartlang.org\flutter_osm_plugin-0.6.7+3\android\src\main\kotlin\hamza\dali\flutter_osm_plugin\OsmFactory.kt: (24, 24): Expecting a parameter declaration
e: C:\Users\prabhunt\Downloads\flutter_windows_2.0.2-stable\flutter.pub-cache\hosted\pub.dartlang.org\flutter_osm_plugin-0.6.7+3\android\src\main\kotlin\hamza\dali\flutter_osm_plugin\OsmFactory.kt: (33, 27): Expecting an argument
e: C:\Users\prabhunt\Downloads\flutter_windows_2.0.2-stable\flutter.pub-cache\hosted\pub.dartlang.org\flutter_osm_plugin-0.6.7+3\android\src\main\kotlin\hamza\dali\flutter_osm_plugin\network\ApiClient.kt: (17, 39): Expecting a parameter declaration
e: C:\Users\prabhunt\Downloads\flutter_windows_2.0.2-stable\flutter.pub-cache\hosted\pub.dartlang.org\flutter_osm_plugin-0.6.7+3\android\src\main\kotlin\hamza\dali\flutter_osm_plugin\utilities\FlutterPickerViewOverlay.kt: (10, 34): Expecting a parameter declaration

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':flutter_osm_plugin:kaptGenerateStubsDebugKotlin'.

Compilation error. See log for more details

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.