Custom Laravel Nova 4 map detail field using Leaflet. Supports Google Maps, marker clustering, map height, latitude and longitude coordinates, GeoJSON, marker popup and custom marker icons.
composer require imumz/nova-4-field-map
use Imumz\Nova4FieldMap\Nova4FieldMap
...
Nova4FieldMap::make()
Nova4FieldMap::make()
->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).
Nova4FieldMap::make()
->googleApiKey('')
->googleMapType('roadmap'), // roadmap, satellite or hybrid
Nova4FieldMap::make('')
->type('LatLon')
->point($this->my_latitude,$this->my_longitude)
Nova4FieldMap::make()
->type('GeoJson')
->geoJson('')
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {
"popup": "I am a Popup"
},
"geometry": {
"type": "Point",
"coordinates": [
23.8623046875,
-30.221101852485987
]
}
}
]
}
Nova4FieldMap::make()
->popup('popup')
Nova4FieldMap::make()
->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])