Skip to content

Commit 255ccd6

Browse files
authored
feat: Add example application for iOS, Android, and macOS, and introduce v6 API models. (#104)
1 parent 9c2f3f9 commit 255ccd6

119 files changed

Lines changed: 4760 additions & 409 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/dart.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,14 @@ jobs:
1111
- name: "Checkout"
1212
uses: actions/checkout@v2 # required!
1313

14+
- name: Create credentials.dart
15+
run: |
16+
rm -f test/credentials.dart
17+
echo "const MAPBOX_KEY = '${{ secrets.MAPBOX_KEY }}';" > test/credentials.dart
18+
1419
- name: ">> Flutter package <<"
1520
uses: k-paxian/dart-package-publisher@master
1621
with:
1722
credentialJson: ${{ secrets.CREDENTIAL_JSON }}
1823
flutter: true
19-
skipTests: true
24+
skipTests: false

.vscode/launch.json

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"name": "mapbox_search",
9+
"request": "launch",
10+
"type": "dart"
11+
},
12+
{
13+
"name": "example",
14+
"cwd": "example",
15+
"program": "lib/main.dart",
16+
"request": "launch",
17+
"type": "dart"
18+
},
19+
{
20+
"name": "example (profile mode)",
21+
"cwd": "example",
22+
"program": "lib/main.dart",
23+
"request": "launch",
24+
"type": "dart",
25+
"flutterMode": "profile"
26+
},
27+
{
28+
"name": "example (release mode)",
29+
"cwd": "example",
30+
"program": "lib/main.dart",
31+
"request": "launch",
32+
"type": "dart",
33+
"flutterMode": "release"
34+
}
35+
]
36+
}

.vscode/settings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"dart.projectSearchDepth": 5
3+
}

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
# [4.4.0] - 30 Dec 2025
2+
- Added Batch Geocoding support (v6) with `batch()` method.
3+
- Improved Static Image API:
4+
- Fixed URL encoding for polylines.
5+
- Added `auto` parameter for automatic viewport adjustment.
6+
- Added `center` parameter requirement check for manual framing.
7+
- Enhanced Example App with tabs for Geocoding, Batch, and Static Images.
8+
19
# [4.3.2] - 11 Aug 2025
210
- Fixed Typecasting issue in `BBox` (Fix #100)
311

README.md

Lines changed: 43 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -107,61 +107,83 @@ Future<ApiResponse<List<MapBoxPlace>>> getPlaces() =>
107107
);
108108
```
109109

110+
### Batch Geocoding (v6)
111+
Perform multiple geocoding queries (forward, reverse, or structured) in a single request.
112+
113+
```dart
114+
var geocoding = GeoCodingApiV6(
115+
apiKey: 'API Key', // or use MapBoxSearch.init('API KEY')
116+
limit: 5,
117+
);
118+
119+
Future<ApiResponse<BatchGeocodingResponse>> getBatch() =>
120+
geocoding.batch([
121+
ForwardQuery(query: "Eiffel Tower", limit: 1),
122+
ReverseQuery(location: (lat: 40.6892, long: -74.0445), limit: 1),
123+
]);
124+
```
125+
110126
### Static Image
127+
111128
```dart
112-
MapBoxStaticImage staticImage = MapBoxStaticImage(
113-
apiKey: 'API Key', // dont pass if you have set it in MapBoxSearch.init('API KEY')
129+
StaticImage staticImage = StaticImage(
130+
apiKey: 'API Key', // or use MapBoxSearch.init('API KEY')
114131
);
115132
```
116133

117134
### Image With Polyline
118135
```dart
119136
String getStaticImageWithPolyline() => staticImage.getStaticUrlWithPolyline(
120-
point1: Location(lat: 37.77343, lng: -122.46589),
121-
point2: Location(lat: 37.75965, lng: -122.42816),
122-
marker1: MapBoxMarker( markerColor: Colors.black,
123-
markerLetter: MakiIcons.aerialway.value,
124-
markerSize: MarkerSize.LARGE),
137+
point1: (lat: 37.77343, long: -122.46589),
138+
point2: (lat: 37.75965, long: -122.42816),
139+
marker1: MapBoxMarker( markerColor: const RgbColor(0, 0, 0),
140+
markerLetter: 'p',
141+
markerSize: MarkerSize.LARGE),
125142
marker2: MapBoxMarker(
126-
markerColor: Color.rgb(244, 67, 54),
143+
markerColor: const RgbColor(244, 67, 54),
127144
markerLetter: 'q',
128145
markerSize: MarkerSize.SMALL),
129146
height: 300,
130147
width: 600,
131-
zoomLevel: 16,
132-
style: MapBoxStyle.Mapbox_Dark,
133-
path: MapBoxPath(pathColor: Color.rgb(255, 0, 0), pathOpacity: 0.5, pathWidth: 5),
134-
render2x: true);
135-
```
148+
zoomLevel: 15.5,
149+
style: MapBoxStyle.Dark,
150+
path: MapBoxPath(pathColor: const RgbColor(255, 0, 0), pathOpacity: 0.5, pathWidth: 5, pathPolyline: "%7DrpeFxbnjVsFwdAvr%40cHgFor%40jEmAlFmEMwM_FuItCkOi%40wc%40bg%40wBSgM"),
151+
render2x: true,
152+
center: (lat: 37.766541503617475, long: -122.44702324243272), // Required when auto is false
153+
// auto: true, // Alternatively, use auto: true to automatically fit markers and path
154+
);
155+
```
136156

137157
### Image with Marker
138158
```dart
139159
String getStaticImageWithMarker() => staticImage.getStaticUrlWithMarker(
140-
center: Location(lat: 37.77343, lng: -122.46589),
160+
center: (lat: 37.77343, long: -122.46589),
141161
marker: MapBoxMarker(
142-
markerColor: Color.rgb(0, 0, 0), markerLetter: 'p', markerSize: MarkerSize.LARGE),
162+
markerColor: const RgbColor(0, 0, 0), markerLetter: 'p', markerSize: MarkerSize.LARGE),
143163
height: 300,
144164
width: 600,
145165
zoomLevel: 16,
146-
style: MapBoxStyle.Mapbox_Streets,
166+
style: MapBoxStyle.Streets,
147167
render2x: true,
148168
);
149169
```
150170

151171
### Image without Marker
152172
```dart
153173
String getStaticImageWithoutMarker() => staticImage.getStaticUrlWithoutMarker(
154-
center: Location(lat: 37.75965, lng: -122.42816),
174+
center: (lat: 37.75965, long: -122.42816),
155175
height: 300,
156176
width: 600,
157177
zoomLevel: 16,
158-
style: MapBoxStyle.Mapbox_Outdoors,
178+
style: MapBoxStyle.Outdoors,
159179
render2x: true,
160180
);
161181
```
162-
# Screenshots
163182

164-
## Static Map Image
183+
### Example App
184+
Check out the `example/` directory for a complete Flutter application demonstrating:
185+
- Forward & Reverse Geocoding
186+
- Batch Geocoding
187+
- Static Images (Markers, Polylines, Auto-framing)
165188

166-
<img src="https://github.com/ketanchoyal/mapbox_search/raw/dev/Screenshots/staticImages.png" alt="Static Map Image"/>
167189

Screenshots/staticImages.png

-941 KB
Binary file not shown.

example/.gitignore

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Miscellaneous
2+
*.class
3+
*.log
4+
*.pyc
5+
*.swp
6+
.DS_Store
7+
.atom/
8+
.build/
9+
.buildlog/
10+
.history
11+
.svn/
12+
.swiftpm/
13+
migrate_working_dir/
14+
15+
# IntelliJ related
16+
*.iml
17+
*.ipr
18+
*.iws
19+
.idea/
20+
21+
# The .vscode folder contains launch configuration and tasks you configure in
22+
# VS Code which you may wish to be included in version control, so this line
23+
# is commented out by default.
24+
#.vscode/
25+
26+
# Flutter/Dart/Pub related
27+
**/doc/api/
28+
**/ios/Flutter/.last_build_id
29+
.dart_tool/
30+
.flutter-plugins-dependencies
31+
.pub-cache/
32+
.pub/
33+
/build/
34+
/coverage/
35+
36+
# Symbolication related
37+
app.*.symbols
38+
39+
# Obfuscation related
40+
app.*.map.json
41+
42+
# Android Studio will place build artifacts here
43+
/android/app/debug
44+
/android/app/profile
45+
/android/app/release

example/.metadata

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# This file tracks properties of this Flutter project.
2+
# Used by Flutter tool to assess capabilities and perform upgrades etc.
3+
#
4+
# This file should be version controlled and should not be manually edited.
5+
6+
version:
7+
revision: "f6ff1529fd6d8af5f706051d9251ac9231c83407"
8+
channel: "stable"
9+
10+
project_type: app
11+
12+
# Tracks metadata for the flutter migrate command
13+
migration:
14+
platforms:
15+
- platform: root
16+
create_revision: f6ff1529fd6d8af5f706051d9251ac9231c83407
17+
base_revision: f6ff1529fd6d8af5f706051d9251ac9231c83407
18+
- platform: macos
19+
create_revision: f6ff1529fd6d8af5f706051d9251ac9231c83407
20+
base_revision: f6ff1529fd6d8af5f706051d9251ac9231c83407
21+
22+
# User provided section
23+
24+
# List of Local paths (relative to this file) that should be
25+
# ignored by the migrate tool.
26+
#
27+
# Files that are not part of the templates will be ignored by default.
28+
unmanaged_files:
29+
- 'lib/main.dart'
30+
- 'ios/Runner.xcodeproj/project.pbxproj'

example/README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# example_flutter
2+
3+
A new Flutter project.
4+
5+
## Getting Started
6+
7+
This project is a starting point for a Flutter application.
8+
9+
A few resources to get you started if this is your first Flutter project:
10+
11+
- [Lab: Write your first Flutter app](https://docs.flutter.dev/get-started/codelab)
12+
- [Cookbook: Useful Flutter samples](https://docs.flutter.dev/cookbook)
13+
14+
For help getting started with Flutter development, view the
15+
[online documentation](https://docs.flutter.dev/), which offers tutorials,
16+
samples, guidance on mobile development, and a full API reference.

example/analysis_options.yaml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# This file configures the analyzer, which statically analyzes Dart code to
2+
# check for errors, warnings, and lints.
3+
#
4+
# The issues identified by the analyzer are surfaced in the UI of Dart-enabled
5+
# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be
6+
# invoked from the command line by running `flutter analyze`.
7+
8+
# The following line activates a set of recommended lints for Flutter apps,
9+
# packages, and plugins designed to encourage good coding practices.
10+
include: package:flutter_lints/flutter.yaml
11+
12+
linter:
13+
# The lint rules applied to this project can be customized in the
14+
# section below to disable rules from the `package:flutter_lints/flutter.yaml`
15+
# included above or to enable additional rules. A list of all available lints
16+
# and their documentation is published at https://dart.dev/lints.
17+
#
18+
# Instead of disabling a lint rule for the entire project in the
19+
# section below, it can also be suppressed for a single line of code
20+
# or a specific dart file by using the `// ignore: name_of_lint` and
21+
# `// ignore_for_file: name_of_lint` syntax on the line or in the file
22+
# producing the lint.
23+
rules:
24+
# avoid_print: false # Uncomment to disable the `avoid_print` rule
25+
# prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule
26+
27+
# Additional information about this file can be found at
28+
# https://dart.dev/guides/language/analysis-options

0 commit comments

Comments
 (0)