fleaflet / flutter_map

A versatile mapping package for Flutter. Simple and easy to learn, yet completely customizable and configurable, it's the best choice for mapping in your Flutter app.
https://pub.dev/packages/flutter_map
BSD 3-Clause "New" or "Revised" License
2.76k stars 860 forks source link

Error: Method not found: 'LatLng'. #625

Closed Zaboy15 closed 3 years ago

Zaboy15 commented 4 years ago

Hello , I Have error this Error: Method not found: 'LatLng'.

import 'package:flutter/material.dart';
import 'package:flutter_map/flutter_map.dart';

class DataMaps extends StatefulWidget {
  @override
  _DataMapsState createState() => _DataMapsState();
}

class _DataMapsState extends State<DataMaps> {

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(),
      body:  new FlutterMap(
    options: new MapOptions(
      center: LatLng(51.5, -0.09),
      zoom: 13.0,
    ),
    layers: [
      new TileLayerOptions(
        urlTemplate: "https://api.tiles.mapbox.com/v4/"
            "{id}/{z}/{x}/{y}@2x.png?access_token={accessToken}",
        additionalOptions: {
          'accessToken': 'Key',
          'id': 'mapbox.streets',
        },
      ),
      new MarkerLayerOptions(
        markers: [
          new Marker(
            width: 80.0,
            height: 80.0,
            point:  LatLng(51.5, -0.09),
            builder: (ctx) =>
            new Container(
              child: new FlutterLogo(),
            ),
          ),
        ],
      ),
    ],
      )

    );
  }
}
PatrykGala commented 4 years ago

You need import latlong.dart: import 'package:latlong/latlong.dart';

SaileshVerma commented 4 years ago

after importing the import 'package:latlong/latlong.dart'; still i m unable to use Latlng pls help its shows Latlng not defined

Swepilot commented 4 years ago

And you have added it to your pubspec.yaml?

https://pub.dev/packages/latlong/install

github-actions[bot] commented 3 years ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

github-actions[bot] commented 3 years ago

This issue was closed because it has been stalled for 5 days with no activity.

SunnyMittal commented 3 years ago

this issue still exists :( created a flutterMap widget as suggested on this link, but i see squiggly red line below the LatLng method name.

https://pub.dev/packages/flutter_map

image

ibrierley commented 3 years ago

You need to import latlong2 0.8.0 not latlong. If you have problems still, do a "flutter pub deps" and it will probably highlight it's using an old latlng somewhere.

abdulsamad110 commented 3 years ago

First Import This to pubspec.yaml av Then Import this bv Then Error will be resolved cv