# Api Plugin Source: https://maps.vietmap.vn/docs/sdk-mobile/Flutter/api-plugin/ A package for using the [VietMap APIs](https://maps.vietmap.vn/docs/map-api/overview/) in Dart. # Vietmap API Flutter plugin [

](https://maps.vietmap.vn) Get an API key: [register for free on VIETMAP Console](https://maps.vietmap.vn/console-v2/register). !!! warning "Use the V4 methods" `vietmap_flutter_plugin` 0.5.2 has two sets of methods. `autocomplete`, `geoCode`, `reverse` and `place`, used in the examples below, call the v3 APIs; for the v4 APIs and the post-merger address format use `autocompleteV4`, `geoCodeV4`, `reverseV4` and `placeV4`. `routing` and `matrix` still call the legacy endpoints (`api-version=1.1`); for toll costs or truck routing, call [Route v4](https://maps.vietmap.vn/docs/map-api/route-version/route-v4/) directly over HTTP. ## Getting started Add library to pubspec.yaml file ```yaml vietmap_flutter_plugin: latest_version ``` Check the latest version at [https://pub.dev/packages/vietmap_flutter_plugin](https://pub.dev/packages/vietmap_flutter_plugin) or run this command in the terminal to add the library to the project: ```bash flutter pub add vietmap_flutter_plugin ``` ## Usage ### Init plugin - You must call `Vietmap.getInstance(apiKey)` before using any other methods. ```dart Vietmap.getInstance('YOUR_API_KEY_HERE'); ``` - We provide below methods to use Vietmap APIs: ```dart Vietmap.autocomplete(VietMapAutoCompleteParams(textSearch: 'Hà Nội')); Vietmap.geoCode(VietMapAutoCompleteParams(textSearch: 'Hà Nội')); Vietmap.reverse(LatLng(21.027763, 105.834160)); Vietmap.place('Place ID'); Vietmap.routing(VietMapRoutingParams(points: [ LatLng(21.027763, 105.834160), LatLng(21.027763, 105.834160) ])); /// This function is used to get the style url of Vietmap, /// which provide the style of the map for VietmapGL plugin. Vietmap.getVietmapStyleUrl(); ``` ## Additional information This package is a part of [Vietmap API](https://maps.vietmap.vn) project. ## Troubleshooting Our plugin depend on [dio](https://pub.dev/packages/dio) and [dartz](https://pub.dev/packages/dartz) package with latest version. If our plugin conflict with your current project, please try to use the latest version of these packages or follow the instruction below: ```yaml dependencies: dio: your_project_version dartz: your_project_version dependencies_override: dio: our_plugin_version dartz: our_plugin_version ``` We use [dartz](https://pub.dev/packages/dartz) package to response the api result. Please check the [dartz](https://pub.dev/packages/dartz) package to know how to handle the result. ```dart var autocompleteData = await Vietmap.autocomplete(VietMapAutoCompleteParams(textSearch: 'Hà Nội')); autocompleteData.fold( (Failure left) { // Handle error here }, (List right) { // Handle success here }, ); ``` ## Note: Replace apikey which is provided by VietMap to all YOUR_API_KEY_HERE tag to the application work normally [

](https://maps.vietmap.vn) Email us: [maps.info@vietmap.vn](mailto:maps.info@vietmap.vn) Vietmap API and price [here](https://maps.vietmap.vn) Contact for [support](https://maps.vietmap.vn/web#contact-section) Vietmap API document [here](https://maps.vietmap.vn/docs/map-api/overview/) Have a bug to report? [Open an issue](https://github.com/vietmap-company/vietmap_flutter_plugin/issues). If possible, include a full log and information which shows the issue. Have a feature request? [Open an issue](https://github.com/vietmap-company/vietmap_flutter_plugin/issues). Tell us what the feature should do and why you want the feature.