Custom Laravel Nova 4 form field for create and update using Leaflet to retrieve coordinates from a clickable map marker. Supports Search, Google Maps, map height, marker popup and custom marker icons.
composer require imumz/nova-4-map-coordinates
use Imumz\Nova4MapCoordinates\Nova4MapCoordinates
...
Nova4MapCoordinates::make('Coordinates')
Nova4MapCoordinates::make('Coordinates')
->height('400px') // default is 300px
By default the provider is OpenStreetMaps.
You must set your Google Maps API key (https://developers.google.com/maps/documentation/javascript/get-api-key).
Nova4MapCoordinates::make('Coordinates')
->googleApiKey('')
->googleMapType('roadmap'), // roadmap, satellite or hybrid
Nova4MapCoordinates::make('Coordinates')
->defaultTileProvider('google') // google, openstreetmap
Nova4MapCoordinates::make('Coordinates')
->defaultLatitude()
->defaultLongitude()
Set the zoom level. Default is 8.
Nova4MapCoordinates::make('Coordinates')
->zoom(12)
The search provider is a work in progress. Default is ESRI.
You can pass additional parameters to the searchProviderOptions
method
Nova4MapCoordinates::make('Coordinates')
->searchProviderOptions([
'sourceCountry' => 'ZA',
])
The coordinates input field can be hidden
Nova4MapCoordinates::make('Coordinates')
->showMapCoordinates(false)
Nova4MapCoordinates::make('Coordinates')
->markerIcon('/images/marker-icon.png')
You can pass additional parameters to set the icon size and anchor
->markerIcon('/images/marker-icon.png',[100,100],[50,50])