wm/map-multi-linestring

A Laravel Nova field.

v0.0.10 2024-08-20 12:56 UTC

README

Map Multi Linestring, awesome resource field for Nova

Version

Requirements

  • php: ^8
  • laravel/nova: ^4

Installation

You can install the package in to a Laravel app that uses Nova via composer:

composer require wm/map-multi-linestring

Develop

create anova-components folder in the root of the project where you want to develop. Clone map-multi-linestring inside. add in "repositories" array attribute of composer.json

        {
            "type": "path",
            "url": "./nova-components/map-multi-linestring"
        }

modify in "requires" object attribute of composer.json

    "wm/map-multi-linestring": "*",

in the first time

launch inside the repository hosting the field

    cd vendor/laravel/nova && npm install

we need modify composer.lock launch

    composer update wm/map-multi-linestring

launch inside field

    npm install

Usage

Map Multi Linestring

image

You can display a post gist geography(MultiLineString,4326) area on the map and change it by uploading a new MultiLineString file (.GPX, .KML, .GEOJSON). To use the Map Multi Linestring feature, include the MapMultiLinestring class and add it to your resource's fields. Customize the map settings by providing metadata such as the initial map center, tile server URL, attribution text, minimum and maximum zoom levels, default zoom level, GraphHopper API URL used to specify the URL of the GraphHopper API, and GraphHopper routing profile used by GraphHopper when calculating the route. Routing profiles determine the type of transportation mode and the set of rules that the routing engine will use. The default value for this field is 'foot', which means the routing will be optimized for walking. Other available profiles include 'bike' and 'hike'.

    use Wm\MapMultiLinestring\MapMultiLinestring;
    /**
     * Get the fields displayed by the resource.
     *
     * @param  \Laravel\Nova\Http\Requests\NovaRequest  $request
     * @return array
     */
    public function fields(NovaRequest $request)
    {
        return [
            ID::make()->sortable(),
                ...
            MapMultiLinestring::make('geometry')->withMeta([
                'center' => [42, 10],
                'attribution' => '<a href="https://webmapp.it/">Webmapp</a> contributors',
                'tiles' => 'https://api.webmapp.it/tiles/{z}/{x}/{y}.png',
                'minZoom' => 5,
                'maxZoom' => 17,
                'defaultZoom' => 10,
                'graphhopper_api' => 'https://graphhopper.webmapp.it/route',
                'graphhopper_profile' => 'hike'
            ]),
        ];
    }

Configuration

As of v1.4.0 it's possible to use a Tab class instead of an array to represent your tabs.