承接 avcodewizard/google-place-api 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

avcodewizard/google-place-api

最新稳定版本:1.0.2

Composer 安装命令:

composer require avcodewizard/google-place-api

包简介

A Laravel package for Google Places API integration

README 文档

README

Total Downloads Latest Stable Version License

A Laravel package for interacting with the Google Places API. This package allows you to search for cities, states, nearby shops, restaurants, and other places based on user input or geographic coordinates.

Features

  • Search Places: Autocomplete feature to search cities, states, and places based on a query.
  • Nearby Places: Find nearby shops, restaurants, and more based on latitude, longitude, and a radius.

Installation

1. Install the Package

You can install this package via Composer by running the following command in your Laravel project:

composer require avcodewizard/google-place-api

2. Set API Key

Add your Google Places API Key to your .env file:

GOOGLE_PLACES_API_KEY=your_google_places_api_key

Usage

Searching for a Place

You can use the GooglePlacesApiService to search for cities, states, or other places via query.

use Avcodewizard\GooglePlaceApi\GooglePlacesApi;

class PlaceController extends Controller
{

    public function searchPlace(Request $request)
    {
        $query = $request->input('query');
        $googlePlaces = new GooglePlacesApi();
        $results = $googlePlaces->searchPlace($query);

        return response()->json($results);
    }
}

Finding Place Details

You can find place details like full address, opening_hours, geometry(lat,lng), photos, rating, reviews etc., using placeId.

public function placeDetails($placeId)
{
    $placeApi = new GooglePlacesApi();
    $results = $placeApi->getPlaceDetails($placeId);

    return response()->json($results);
}

Finding Nearby Places

You can find nearby places like restaurants, shops, etc., using geographic coordinates (latitude and longitude) along with a search radius.

public function nearbyPlaces(Request $request)
{
    $latitude = $request->input('latitude');
    $longitude = $request->input('longitude');
    $radius = $request->input('radius');
    $type = $request->input('type'); // Optional: e.g., 'restaurant', 'store'

    $results = $this->googlePlaces->findNearbyPlaces($latitude, $longitude, $radius, $type);

    return response()->json($results);
}

Requirements

  • PHP 7.3 or higher
  • Laravel 8.x or higher
  • Google Place API key

Contribution

Feel free to report issues or make Pull Requests. If you find this document can be improved in any way, please feel free to open an issue for it.

License

MIT

统计信息

  • 总下载量: 6.6k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 7
  • 点击次数: 3
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 7
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-10-10