Code Monkey home page Code Monkey logo

nova-map-marker-field's Introduction

This package has been archived until such time that it can be brought up-to-date with Laravel Nova. We have stopped using Laravel Nova, and no longer have a license for it. As such we currently cannot justify further development on this package. Please check here for availability of similar packages: https://novapackages.com

Map Marker Field for Laravel Nova

GitHub (pre-)release Packagist GitHub license

Map Marker Field for Laravel Nova masthead image.

Supporting This Package

This is an MIT-licensed open source project with its ongoing development made possible by the support of the community. If you'd like to support this, and our other packages, please consider becoming a sponsor.

We thank the following sponsors for their generosity, please take a moment to check them out:

Requirements

  • Laravel 9.0+
  • Nova 3.9+

Installation

  1. Install the package:
composer require genealabs/nova-map-marker-field
  1. Publish the marker icon assets (this is not necessary if you are specifying your own):
php artisan vendor:publish --provider="GeneaLabs\NovaMapMarkerField\Providers\Service"

Implementation

To create the map marker field, all that is necessary is the form label, and the remaining options will have defaults applied:

use GeneaLabs\NovaMapMarkerField\MapMarker;

MapMarker::make("Location"),

Coordinate Field Names

By default the field will look for latitude and longitude fields on the model. However, if your model uses different names, you may customize them with the ->latitude('lat') and ->longitude('long') methods:

MapMarker::make("Location")
    ->latitude('lat')
    ->longitude('long'),

Default Settings

You can specify default settings for zoom level, and initial map center coordinates. If not specified, the zoom level will default to 12; the coordinates will default to (0, 0).

MapMarker::make("Location")
    ->defaultZoom(8)
    ->defaultLatitude(41.823611)
    ->defaultLongitude(-71.422222),

Center Circle

The optional centerCircle() method allows the addition of a circle to be rendered at the centerpoint of the map.

MapMarker::make("Location")
    ->centerCircle($radiusInMeters, $color, $borderWidth, $backgroundOpacity),

Search Provider

The underlying search capabilities are provided by leaflet-geosearch. Please refer to their documentation for provider configuration. By default we use the ESRI search provider.

MapMarker::make("Location")
    ->searchProvider('google')
    ->searchProviderKey('xxxxxxxxxxxxxxxxxxxxxxxxxxx'),

You can specify a custom search label in the geosearch box:

MapMarker::make('Location')
    ->searchLabel('Enter Address');

Tile Layer

You are free to use any tile provider that is compatible with Leaflet. Please refer to their documentation on tile layer URLs. By default we use tiles provided by OpenStreetMap:

MapMarker::make("Location")
    ->tileProvider('http://{s}.somedomain.com/{foo}/{z}/{x}/{y}.png'),

Recenter On Nova Custom Component Events

  • From your custom component you can trigger the recentering of the map as follows:
    Nova.$emit("recenterMapOn", {latitude, longitude});
  • You can define a custom event name that the MapMarker field will respond to:
    MapMarker::make('Location')
        ->listenToEventName('customCenterEventTriggerName');
    You can then trigger the event from your custom component like so:
    Nova.$emit("customCenterEventTriggerName", {latitude, longitude});

Usage

When creating or editing you can search for an address or city to get the map to the general area you wish to get coordinates for. Then you can precisely position the marker by dragging the map -- the marker will always stay positioned in the middle, while you move the map under it.

When viewing the map in on the detail page, the map and marker are not interactive, and there is no search functionality. However, the user is free to zoom in and out.

Screenshots

Create / Edit Field

Screen Shot 2019-06-23 at 8 16 52 AM

Detail Field

Screen Shot 2019-06-23 at 8 17 43 AM

Index Field

Screen Shot 2019-06-23 at 8 32 01 AM

Commitment to Quality

During package development I try as best as possible to embrace good design and development practices, to help ensure that this package is as good as it can be. My checklist for package development includes:

  • ✅ Achieve as close to 100% code coverage as possible using unit tests.
  • ✅ Eliminate any issues identified by SensioLabs Insight and Scrutinizer.
  • ✅ Be fully PSR1, PSR2, and PSR4 compliant.
  • ✅ Include comprehensive documentation in README.md.
  • ✅ Provide an up-to-date CHANGELOG.md which adheres to the format outlined at http://keepachangelog.com.
  • ✅ Have no PHPMD or PHPCS warnings throughout all code.

Contributing

Please observe and respect all aspects of the included Code of Conduct https://github.com/GeneaLabs/nova-map-marker-field/blob/master/CODE_OF_CONDUCT.md.

Reporting Issues

When reporting issues, please fill out the included template as completely as possible. Incomplete issues may be ignored or closed if there is not enough information included to be actionable.

Submitting Pull Requests

Please review the Contribution Guidelines https://github.com/GeneaLabs/nova-map-marker-field/blob/master/CONTRIBUTING.md. Only PRs that meet all criterium will be accepted.

If you ❤️ open-source software, give the repos you use a ⭐️.

We have included the awesome symfony/thanks composer package as a dev dependency. Let your OS package maintainers know you appreciate them by starring the packages you use. Simply run composer thanks after installing this package. (And not to worry, since it's a dev-dependency it won't be installed in your live environment.)

nova-map-marker-field's People

Contributors

angelformica avatar checkerschaf avatar energon7 avatar jazo avatar jolora avatar mikebronner avatar nicko170 avatar orclyx avatar s0ulf7y avatar tanerkay avatar vbezruchkin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

nova-map-marker-field's Issues

Is it possible to put several markers in a map ?

Hi,

I manage an app for collective autoconsumptions. There is one producer with solar panels on his roof, and several consumers that will consume his local energy.

When showing detail of each consumers, I can manage it easily, but when I need to show a map for the operation with all actors ( I can have a lot of consumers / producers ) in a 2 km diameter, I don't know how to do it. Circle would be quite nice to draw the limits of operation ( the 2 km diameter ) but I don't know if it is possible to add several markers in a map ? Is it ?

CORS error

Describe the bug
During the search on map, response gives CORS error. On AWS (amazonaws.com) and localhost as well.

To Reproduce
Steps to reproduce the behavior:

  1. Go to map field
  2. Enter text
  3. Response will be CORS error

Expected behavior
Response should be valid JSON with map details.

The field doesn't shown in create form

The map field doesn't shown in creation form !!

MapMarker::make('Location')
                ->latitude('latitude')
                ->longitude('longitude')
                ->defaultZoom(8)
                ->defaultLatitude(41.823611)
                ->defaultLongitude(-71.422222)
                ->rules(['required'])

composer.json

        "genealabs/nova-map-marker-field": "^0.1.16",
        "laravel/framework": "^7.0",

nova version v3.3.2

@mikebronner

Feature: Default settings for all instances

Hi,

Thanks again for the great plugin.
Please add configuration for default MapMarker values, so I don't need to setup it for every model I have.

Example:

  • I have several models located in one city
  • I use MapMarker in several files with the default values

It would be easier for my case to have just one default configuration (latitude, longitude, zoom, etc.) and it would be applied to all calls.

Thanks in advance.

Marker doesn't stay in correct spot when zooming with scroll wheel on Detail view

The marker is locked to the middle of the screen, but if you put your mouse near the corner of the image and scroll in/out the frame shifts to the left/right, but the marker bounces back to the center of the map, which ends up being in the wrong location. Starting with the map zoomed in to street level, you can zoom out with your scroll wheel on your mouse and move the marker clear across the globe.

Suggested fix: don't force the marker to be "centered" on the detail view, but keep it centered on the edit/create view.

laravel 7 support

hi,

can you update the package to also support laravel 7 please?

thanks

Support for Storing lat/long in mysql Geo Point field

We've been using mysql's geo Point() field for storing the latitude and longitude values. I wrote a quick override to the fillAttributeFromRequest to handle this in our app. Is there any interest in merging this type of support into the main repo?
Cheers

MapMarker field in Nova tabs

Hi. Very nice package, thank you!

I find some issue with Map field, while use Nova tabs inside my resource.

For tabs I use "eminiarts/nova-tabs": "1.2.2"

image

If I use Map field outside of tabs, there are no problems with it.

Nova is required for?

Hello
I am trying to installing but yeah it is asking for nova. The nova is not good for me because must pay for every projects and on the localhost it is problematic if I am trying to test things and after uploading the files to productive webserver.
Which way this package is using the Nova? Why do I need Nova?
Can't I use this package without nova?

Thank you for the answer.

Better nullable support

Currently I can allow nullable with

MapMarker::make('Location')
    ->latitude('lat')
    ->longitude('lng')
    ->nullable()
    ->nullValues([0])

But if the map is moved at all it's impossible to re-nullify it, can we get a button to clear or reset the map? In my case the lat/lng is conditional so even accepting 0 as null was a compromise as that is a real lat/lng.

TypeError: Cannot read property 'latitude' of null

I'm getting the following error on the console with the new update of nova and the package. Tried setting a default value as well but still the same issue.

vendor.js?id=f9725df909a5af18907e:1 TypeError: Cannot read property 'latitude' of null

How I include the field within the Nova model is:

MapMarker::make("Location")->rules('required')->hideFromIndex()->help('Drag the map on to a location or try to search to get the location.'),

Notes:

  • This works on index, and update views.

version: "genealabs/nova-map-marker-field": "^0.1.16",
nova: v3.3.2

Thanks in advance :) Please have a look.

Not accepting custom field names

I am trying to use custom field names by following the documentation:
MapMarker::make('Location') ->latitude('lat') ->longitude('long'),

But these fields stay blank. If I rename these fields to 'latitude' & 'longitude' in my database, everything works great. I do not want to rename my fields though, can you provide any assistance?

Map doesn't refresh on second search try.

Describe the bug
When I submit a search into map search bar, the first time the map gets refreshed. If I submit another search without clearing the bar with the "x button", the map doesn't get refreshed.

To Reproduce
Steps to reproduce the behavior:

  1. Go to Nova Edit resource form.
  2. Click on map search bar
  3. Fill the search bar and press return
  4. Wait for map refresh
  5. Change some data into search bar and press return
  6. Map doesn't refresh.

Expected behavior
Map should refresh after every search submit

Screenshots
If applicable, add screenshots to help explain your problem.

Environment:

  • Device Name & Model: Asus Vivobook
  • OS & Version: Ubuntu 18.04
  • Browser & Version: Chromium Web Browser 90.0.4430.93
  • Laravel Version: 8.12
  • PHP Version: 7.4
  • Package Version: 1

Additional context
Add any other context about the problem here.

Laravel 7 support

Hey, I really love this package and I wish that you could add Laravel 7 support because I want to update my project laravel version..

Thank you

Can't input in the search bar in Safari

Describe the bug
With Safari I can't input value in the search bar.

To Reproduce
Steps to reproduce the behavior:

  1. Go to a field created with nova map marker field with Safari
  2. Try to click in the input field of the search bar
  3. Can't click and can't input value

Expected behavior
That this works as in Google Chrome for example.

Environment:

  • Device Name & Model: MacBook Pro
  • OS & Version: macOS Big Sur 11.3
  • Browser & Version: Safari 14.1
  • Laravel Version: 8.12
  • PHP Version: 7.4
  • Package Version: 0.3.1

Hide map on Detail page if value is empty

On occasion we don't have location data for a particular Model, so on the Detail page the map is defaulting to long/lat 0.

Instead, if the field has no value could we hide the map altogether and have an output such as "Location data not supplied"?

Migration

Hi,

What column type would you use for the migration?

Thanks for a promising package!

//Tim

OSM tile provider, load over https

v 0.1.13

Looks like this old issue is unresolved.

#14

Error:

Mixed Content: The page at '<URL>' was loaded over HTTPS, but requested an insecure image '<URL>'. This content should also be served over HTTPS.
... insecure image 'http://c.tile.osm.org/12/2047/2047.png'. This content should also be served over HTTPS.

parsing failed bad endian byte value 50

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:

  1. Go to edit resource
  2. Click on 'zoom map and select place', when selecting without zooming it is ok, but when zooming, the values saved in the database is long and causing errors
  3. save
  4. See error 'parsing failed: bad endian byte value XX' , XX sometime is 50, 41 or other number

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
Screen Shot 2021-12-07 at 10 44 29 AM

The first row is working fine, the second one is not working and causing the problem:

Screen Shot 2021-12-07 at 10 48 24 AM

Restrictive dependency for Nova as local folder

Hi again,

Looks like the problem, outlined in #17 is still persistent. We have the same problem on some other dev environments.

Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - genealabs/nova-map-marker-field dev-master requires laravel/nova 2.* -> no matching package found.
    - genealabs/nova-map-marker-field dev-master requires laravel/nova 2.* -> no matching package found.
    - Installation request for genealabs/nova-map-marker-field dev-master -> satisfiable by genealabs/nova-map-marker-field[dev-master].

Potential causes:
 - A typo in the package name
 - The package is not available in a stable-enough version according to your minimum-stability setting
   see <https://getcomposer.org/doc/04-schema.md#minimum-stability> for more details.
 - It's a private package and you forgot to add a custom repository to find it

Read <https://getcomposer.org/doc/articles/troubleshooting.md> for further common problems.

Looks like the dependency does not work well, when you include Nova as a local folder:

    "repositories": {
        "laravel/nova": {
            "type": "path",
            "url": "./nova"
        }
    },

it worked fine for me, when I followed your advise and used Nova from regular registry.

Anyhow, quick research shows that if I switch your package composer dependency to * it works just fine. I checked 6 most popular packages from https://novapackages.com/ and they all don't have nova dependency at all or just "laravel/nova": "*"

Please consider to change your package dependency to *

Thanks in advance.

the mab is showing as balnk

hello dear.
I used the backage but something wrong there.
the mab shows as blank mab without any thing.

in my database i used
json(location) : to save long - latut as one columen
it doesnt abbear

but when i used
string(longitude)
string(latitude)

Screenshot from 2020-12-08 09-48-54

Environment:

  • Laravel Version: 8.17
  • PHP Version: 7.4
  • Package Version: 0.3.0

Option to set zoom level

Hey,

it would be very nice to set the default zoom level. Without it kinda ruins the workflow so it would be very nice to add this option.
It's a great package so far, I'll see if I can contribute later.

Thanks and hava a nice day :)

'illegal offset type' whenever I create a resource.

Hello,

First, I would like to thank you for the great package.
Recently, I have the issue 'illegal offset type' whenever I want to create a resource. I think this happened in Laravel Nova v3.8.4 because before that I was able to create a resource fine.

here is my code,

MapMarker::make('Map')
            ->defaultZoom(13)
            ->latitude('latitude')
            ->longitude('longitude'),

is there any temporary solution for this issue?
Thank you.

Validation

Hi,

Would it be possible to add validations to this field?

I would like to set the field as 'required'

Thanks in advance

//Tim

Custom latitude and longitude fields not working without required

I've tried setting custom attributes and was debugging this for an hour and found out I need to make the field required so it works with custom atttributes.

            MapMarker::make("Location")
                ->latitude('location_lat')
                ->longitude('location_lng')
                ->defaultZoom(12)
                ->defaultLatitude('45.25')
                ->defaultLongitude('19.83')
                ->tileProvider('https://{s}.basemaps.cartocdn.com/rastertiles/voyager/{z}/{x}/{y}.png')
                ->centerCircle(env('DEFAULT_RANGE'), 'red', 1, 0.2)
                ->required()
                ->hideFromIndex(),

works

            MapMarker::make("Location")
                ->latitude('location_lat')
                ->longitude('location_lng')
                ->defaultZoom(12)
                ->defaultLatitude('45.25')
                ->defaultLongitude('19.83')
                ->tileProvider('https://{s}.basemaps.cartocdn.com/rastertiles/voyager/{z}/{x}/{y}.png')
                ->centerCircle(env('DEFAULT_RANGE'), 'red', 1, 0.2)
//                ->required()
                ->hideFromIndex(),

this doesn't work

Google search provider does not work

Describe the bug
When I set Google as a provider, it does not change.
API key is good and working in the other parts of applicaiton

To Reproduce
Steps to reproduce the behavior:

            MapMarker::make("Location")
                ->defaultZoom(18)
                ->searchProvider('google')
                ->searchProviderKey(env('GOOGLE_MAPS_GEOCODING_API_KEY')),

Expected behavior
It should use Google Geocoding API.

Screenshots
DevTools_-ourbeloved_cy_admin_resources_churches_604_edit_and_New_Issue·_GeneaLabs_nova-map-marker-field

Environment:

  • Laravel Version: 8.34.0
  • PHP Version: 8.0.3
  • Package Version: 0.3.1

Laravel 6 support on 0.2.2

Hello,

Thank you for the package. I was wondering is there any specific reason why version 0.2.2 doesn't support Laravel 6 ?
I forked it and changed the composer.json file to allow Laravel 6 and haven't encountered any issues so far.
I'm asking because it might be something I missed.

Thank you

Keep LAT and LONG values when editing

Hi all

Only when editing, it looks like latitude and longitude values are lost, and it shows a random map (with random location and marker).

So I need to type again the entire address to reset the map to the correct values, even if I wanted to edit another field.

Did I make something wrong, or this feature is not developed yet?

Thanks a lot for your help

option to show other markers

Hi, a option to show other markers / or all on the detailpage would be nice.. or maybe only nearby..

thanks
Denis

Assets not compiled for production

Hi,
I've just seen that the nova assets aren't compiled for production.
The console contains development warnings for vue.

Would be nice if you can fix it very quick 😄
If you don't have any time atm I could do it later.

Thanks

Default map provider should use https

I noticed that the default provider for this field is using http instead of https, forcing us to always define the tile provider (even though we're using OSM)

            MapMarker::make("Location")
                ->tileProvider('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png'),

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.