latlngconv 0.1.0

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • new52

latlngconv

A Flutter package to convert latitude and longitude between WGS84, GCJ-02, BD-09, Web Mercator

  • 有偏移需要修正的地图: 百度地图、高德地图、搜狗地图、搜搜地图、谷歌地图(国内服务器)
  • 不需要修正的地图: 天地图、谷歌地球、谷歌卫星地图(国外服务器)、必应卫星地图和OpenStreetMap地图等

Basic usage

//convert wgs84 to gcj02
LatLng wgs = new LatLng(31.1695941, 121.3926092);
LatLng gcj = LatLngConvert(wgs, LatLngType.WGS84, LatLngType.GCJ02);

//convert gcj02 back to wgs84
LatLng wgs2 = LatLngConvert(gcj, LatLngType.GCJ02, LatLngType.WGS84);

//they are expect to nearly equal
// wgs == wgs2

Features and bugs

Please file feature requests and bugs at the issue tracker.

License

Copyright 2015 Michael Mitterer (office@mikemitterer.at),
IT-Consulting and Development Limited, Austrian Branch

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, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
either express or implied. See the License for the specific language
governing permissions and limitations under the License.

[0.0.1] - 2018/12/27.

  • first release.

[0.1.0] - 2018/12/28

  • provide example and fix suggestions by the dartlang pub

example/example.dart

import "package:latlngconv/latlngconv.dart";


void main() {
    //location from gps provider inside china. 
    LatLng wgs = new LatLng(31.1695941, 121.3926092);

    //check if the location is out of china(this method gives a rectangle check. but the actual )
    bool isThisPointOutOfChina = OutofChina(wgs);

    //convert wgs84 to gcj02
    LatLng gcj = LatLngConvert(wgs, LatLngType.WGS84, LatLngType.GCJ02);

    //convert from gcj02 to bd09. (the bd09 could be used by baidumap)
    LatLng bd09 = LatLngConvert(gcj, LatLngType.GCJ02, LatLngType.BD09);

    //convert from wgs to bd09
    LatLng bd09_2 = LatLngConvert(wgs, LatLngType.WGS84, LatLngType.BD09);

    //convert from wgs84 to webmercator
    LatLng mercator = LatLngConvert(wgs, LatLngType.WGS84, LatLngType.WebMercator);
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  latlngconv: ^0.1.0

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter packages get

Alternatively, your editor might support flutter packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:latlngconv/latlngconv.dart';
  
Version Uploaded Documentation Archive
0.1.0 Dec 28, 2018 Go to the documentation of latlngconv 0.1.0 Download latlngconv 0.1.0 archive
0.0.1 Dec 27, 2018 Go to the documentation of latlngconv 0.0.1 Download latlngconv 0.0.1 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
7
Health:
Code health derived from static analysis. [more]
96
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
52
Learn more about scoring.

We analyzed this package on Jan 15, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.1.0
  • pana: 0.12.10
  • Flutter: 1.1.7

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Health suggestions

Fix lib/latlngconv.dart. (-3.93 points)

Analysis of lib/latlngconv.dart reported 8 hints, including:

line 71 col 8: Name non-constant identifiers using lowerCamelCase.

line 83 col 8: Name non-constant identifiers using lowerCamelCase.

line 107 col 8: Name non-constant identifiers using lowerCamelCase.

line 114 col 8: Name non-constant identifiers using lowerCamelCase.

line 121 col 8: Name non-constant identifiers using lowerCamelCase.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.68.0 <3.0.0
flutter 0.0.0
latlong ^0.6.1 0.6.1
Transitive dependencies
ansicolor 1.0.2
collection 1.14.11
console_log_handler 1.1.3
intl 0.15.7
logging 0.11.3+2
meta 1.1.6 1.1.7
path 1.6.2
sky_engine 0.0.99
typed_data 1.1.6
validate 1.7.0
vector_math 2.0.8
Dev dependencies
flutter_test