wdarins/nova-map-address

一个 Laravel Nova 字段,可以在地图上放置标记以获取坐标,然后通过反向地理编码坐标来获取街道地址

安装: 7

依赖: 0

建议者: 0

安全: 0

星标: 0

关注者: 0

分支: 21

语言:Vue

0.1.1 2020-10-05 08:26 UTC

This package is not auto-updated.

Last update: 2024-09-29 00:42:41 UTC


README

一个 Nova 字段,可以在地图上放置标记以获取坐标,然后通过反向地理编码坐标来获取街道地址

安装

您可以通过 composer 在使用 Nova 的 Laravel 应用中安装此包

composer require josrom/nova-map-address

配置

发布包配置文件

php artisan vendor:publish --provider="Josrom\MapAddress\FieldServiceProvider"

这是将要发布的文件内容,发布位置在 config/map-address.php

将以下键值对添加到您的 .env.env.example

MAP_ADDRESS_API_KEY=

Optional: Set map and address language
MAP_ADDRESS_LANGUAGE=es

如果您需要 Google Maps API 密钥,您可以在 Google 开发者控制台创建应用并启用位置 API,然后创建凭据以获取 API 密钥 https://console.developers.google.com

使用

将以下内容添加到 Nova/{Model}.php 资源文件中

use Josrom\MapAddress\MapAddress;

[
    MapAddress::make('address'),

    // You can set the initial map location. By default (Spain)
     MapAddress::make('address')
        ->initLocation(38.261842, -0.6868031),
        
    // You can set the location from the model
    MapAddress::make('address')
        ->setLocation($this->latitude, $this->longitude),
        
    // You can select the name of lat/lng fields. By default is lat/lng
    MapAddress::make('address')
        ->setLatitudeField('latitude')
        ->setLongitudeField('longitude'),
    
    // You can select what is the first result set in address field
    MapAddress::make('address')
        ->setGoogleResultType('street_address'),
    
    // You can also set the map zoom level. By default (4)
     MapAddress::make('address')
        ->initLocation(38.261842, -0.6868031)
        ->zoom(12),
]

Package screenshot

支持

许可证

MIT 许可证 (MIT)。请参阅 许可证文件 以获取更多信息。