실시간 자동 완성 제안을 통해 사용자가 위치를 검색할 수 있는 플러터 위젯입니다. 주소나 위치 선택이 필요한 애플리케이션에서 장소 입력을 간편하게 만들도록 설계되었으며, 양식과 지도에 원활하게 통합됩니다. 타이핑 및 장소 선택을 위한 깔끔하고 직관적인 인터페이스를 제공하여 위치 입력 시 사용자 경험을 향상시킵니다. 사용자가 입력하는 동안 실시간 피드백을 지원해 오류를 줄이고 효율성을 높입니다. 단순성과 성능을 고려해 개발되어, 빠르고 정확한 위치 입력이 필요한 앱에 적합합니다.
사용 사례
위치 기반 앱 검색
양식 내 주소 입력
지도 핀 배치
여행 및 배달 앱
지오로케이션 폼 필드
주요 기능
실시간 자동 완성
간단한 통합
사용자 친화적인 인터페이스
입력 중 동적 피드백
경량이고 빠름
적합한 대상
위치 기능이 있는 모바일 앱
주소 선택이 필요한 앱
간편한 장소 검색을 원하는 개발자
사용자 경험 중심의 위치 입력
미니멀리스트 디자인 요구 사항
고려 사항
자동 완성 기능을 사용하려면 인터넷 연결이 필요합니다
제한된 사용자 정의 옵션
오프라인 지원 없음
외부 지오코딩 서비스에 의존합니다
테마 일치를 위해 추가 스타일링이 필요할 수 있습니다
원본 README
연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.
search_map_place
This is a Flutter package that uses the Google Maps API to make a TextField that tries to autocomplete places as the user types, with simple smooth animations, providing a nice UI and UX.
This will also provide great information about the user selected place, like the coordinates, the bounds to determine the zoom of the GoogleMap widget, and so on.
This is an example of what can be done using this package. To see the source code, check the examples folder.
Getting Started
To install, add it to your pubspec.yaml file:
dependencies:search_map_place:<latest>
After that, make sure you have the following APIs activated in your Google Cloud Platform:
Places
Geolocation
Geocoding
You can now import it to your file and use it on your app.
Where you want to add the search widget, call SearchMapPlaceWidget's constructor:
Widgetbuild(BuildContext context) {
returnScaffold(
body: Center(
child: SearchMapPlaceWidget(
apiKey: // YOUR GOOGLE MAPS API KEY
)
)
);
}
The constructor has 7 attributes related to the API:
String apiKey is the only required attribute. It is the Google Maps API Key your application is using
(Place) void onSelected is a callback function called when the user selects one of the autocomplete options.
(Place) void onSearch is a callback function called when the user clicks on the search icon.
String language is the Language used for the autocompletion. Default is 'en' (english). Check the full list of supported languages for the Google Maps API
LatLng location is the point around which you wish to retrieve place information. If this value is provided, radius must be provided aswell.
int radius is the distance (in meters) within which to return place results. Note that setting a radius biases results to the indicated area, but may not fully restrict results to the specified area. If this value is provided, location must be provided aswell. See Location Biasing and Location Restrict in the Google Maps API documentation.
bool restrictBounds will return only those places that are strictly within the region defined by location and radius.
PlaceType placeType will allow you to filter Places by its type. For more information on available types, check supported types for Autocompletion. On default, no filters are passed to the request, which means all Place types will be shown on autocompletion.
The Place class
This class will be returned on the onSelected and onSearch methods. It allows us to get more information about the user selected place.
Initially, it provides you with only basic information:
description contains the human-readable name for the returned result. For establishment results, this is usually the business name.
placeIdA textual identifier that uniquely identifies a place. For more information about place IDs, see the Place IDs overview.
types contains an array of types that apply to this place. The array can contain multiple values. Learn more about Place types.
fullJSON has the full JSON response received from the Places API. Can be used to extract extra information. More info on the Places Autocomplete API documentation
However, you can get more information like the coordinates and the bounds of the place by calling
await myPlace.geolocation;
Example
Here's an example of the widget being used:
returnSearchMapPlaceWidget(
apiKey: YOUR_API_KEY,
// The language of the autocompletion
language: 'en',
// The position used to give better recomendations. In this case we are using the user position
location: userPosition.coordinates,
radius: 30000,
onSelected: (Place place) async {
final geolocation = await place.geolocation;
// Will animate the GoogleMap camera, taking us to the selected position with an appropriate zoomfinalGoogleMapController controller = await _mapController.future;
controller.animateCamera(CameraUpdate.newLatLng(geolocation.coordinates));
controller.animateCamera(CameraUpdate.newLatLngBounds(geolocation.bounds, 0));
},
);
Future Implementations
There are a lot of features that can be added to this package. Here are some features I want to implement (or could be implemented by someone else):
[ ] Make the widget more personalizable
[ ] Make this package independent of google_maps_flutter
[ ] Allow users to close the box clicking outside of it
[ ] Proper widget dimensions for phones in portrait orientation or foldables.