Your laravel maps libary.

Overview

Laravel map

Latest Version on Packagist Total Downloads GitHub Actions

Laravel maps

This package allows you to easily use leaflet.js or google maps to create a map in your laravel project.

Installation

You can install the package via composer:

composer require larswiegers/laravel-maps

Supported map types

What Basic map Centerpoint Basic markers Zoomlevel Can use different tiles
Leaflet
Google maps

Tilehosts

Openstreetmap

Openstreetmap is a creative commence tile library created by volunteers. No configuration has to be set to use as it is the default tilehost for this library. More information can be found here: openstreetmap.org

Mapbox

Mapbox is a for profit company that also offers free keys. Their map can be more accurate / precise. To get your free key go to mapbox.com Once logged in you can get your free key and use it by placing it in the env file like this MAPS_MAPBOX_ACCESS_TOKEN.

Usage

Leaflet

// Leaflet
// A basic map is as easy as using the x blade component.

<x-maps-leaflet></x-maps-leaflet>

// set the centerpoint of the map:
<x-maps-leaflet :centerPoint="['lat' => 52.16, 'long' => 5]"></x-maps-leaflet>

// set a zoomlevel:
<x-maps-leaflet :zoomLevel="6"></x-maps-leaflet>

// Set markers on the map:
<x-maps-leaflet :markers="[['lat' => 52.16444513293423, 'long' => 5.985622388024091]]"></x-maps-leaflet>

Google maps

// Google maps

// set the centerpoint of the map:
<x-maps-google :centerPoint="['lat' => 52.16, 'long' => 5]"></x-maps-google>

// set a zoomlevel:
<x-maps-google :zoomLevel="6"></x-maps-google>

// Set markers on the map:
<x-maps-google :markers="[['lat' => 52.16444513293423, 'long' => 5.985622388024091]]"></x-maps-google>

Google maps api key

You can get an api key here: console.cloud.google.com Create an api key and enable the Maps Javascript API in the console aswell. Place the api key in the env file like this MAPS_GOOGLE_MAPS_ACCESS_TOKEN

Testing

To run the tests just use the following component:

composer test

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

Comments
  • Popup open when clicked

    Popup open when clicked

    Currently popups do not open when clicked when there is $marker['info'] provided.

    I can submit a PR for this functionality if you think this enhancement would be useful.

    opened by ryangurn 13
  • Missing Tiles

    Missing Tiles

    Hi,

    Does anyone have any ideas why the tiles are not fully loading? See screenshot below.

    I'm using Bootstrap, but I cannot see where any conflicts are coming from. I've also added my Mapbox API key to my .env file. Using Google works OK but I need multiple instances of the map so I need to use the Leaflet option.

    Screenshot 2022-08-10 at 13 59 02 question 
    opened by synecdocheNORTH 11
  • View Publishing

    View Publishing

    I really love this package as it has made the process of displaying maps and coordinates super easy.

    Thank you so much for putting in the time to build this!

    I do have one request for improving the functionality. Currently on both map types you are essentially hardcoding in the height which is making it a bit more difficult to use with css frameworks such as bootstrap and tailwindcss.

    This would be something that I could easily change if the views were published out in the same way that the config file is.

    Would you consider changing uncommenting the following lines in LaravelMapsServiceProvider.php

    ...
    // Publishing the views.
    $this->publishes([
          __DIR__.'/../resources/views' => resource_path('views/vendor/maps'), // changed Laravel-maps to map since that is the value provided in loadViewsFrom
    ], 'views');
    ...
    

    I have done a bit of digging in Laravel's package development documentation and noticed that when using $this->loadViewsFrom it will look in two places. The first of which is the views folder within the package and the second is the views/vendor folder within the resources directory.

    When you use the loadViewsFrom method, Laravel actually registers two locations for your views: the application's resources/views/vendor directory and the directory you specify. So, using the courier package as an example, Laravel will first check if a custom version of the view has been placed in the resources/views/vendor/courier directory by the developer.

    This would allow any other developers to make minor changes to the view without much effort.

    Here is the documentation that I was reading by the way.

    https://laravel.com/docs/9.x/packages#overriding-package-views

    If you would like I can also test this and submit a PR if you would like, please just let me know in the comments on this issue and I can help as needed.

    opened by ryangurn 8
  • #defaultMapId has height of 100vh

    #defaultMapId has height of 100vh

    When using the blade components there is some CSS making the map take up the entire height of the viewport. I have placed the following bit of CSS in my app.css:

    #defaultMapId {
        height: 100% !important;
    }
    

    This obviously fixes the issue but I was wondering if there's a better way of configuring this? Maybe (probably) I'm missing something. 🧐

    PS: I can already see this package saving me a bunch of time in the future!

    enhancement 
    opened by RobertCordes 7
  • Multiple markers dynamically

    Multiple markers dynamically

    I know blade tags dont have to use the {{ and }} to pass data

    https://github.com/LarsWiegers/laravel-maps/issues/6

    Currently, there's no way to add markers dynamically. For instance, I query the DB and get an array of coordinates. Currently you cannot loop through each location to place a marker on a single map (not multiple maps).

    May be there's a way but I can't find it.

    question 
    opened by rjcalifornia 6
  • Added Custom InfoWindow and Icon on Google Maps

    Added Custom InfoWindow and Icon on Google Maps

    Hi Lars, this is a great package!! In one of my projects i need InfoWindow and custom icons on Google Map. I've added this ability to blade template. Hope is useful and you accept PR Thanks for your work

    opened by kikojover 5
  • call x-maps-google with ajax

    call x-maps-google with ajax

    Hello and thank you very much for the effort you put in this package. I am trying to implement the map in the following scenario. A specific user interaction makes an ajax call to a route. From there the controller handles the request by returning a small blade with some information. The controller is using the return view() to send back the blade. Inside this blade I have the . When the ajax request returns, javascript handles it by applying the blade to a div element.

    When doing this, the map is not rendered.

    I notice that if the is rendered onpageload , it pushes some scripts to html . But if the is being rendered afterwards through ajax, the snippets are not pushed to

    Am I approaching this the wrong way? Do you have any suggestions on how to initialize the map asynchronously maybe?

    Thank you for your time.

    enhancement 
    opened by sotirislp 5
  • Maps within wire-elements/modal

    Maps within wire-elements/modal

    When I attempt to use laravel-maps within a wire-elements modal I get the following error.

    @LarsWiegers do you have any recommendations for how to address this? I am currently just using one of the examples from the readme for testing purposes.

    <div class="bg-white overflow-hidden shadow rounded-lg divide-y divide-gray-200">
        <div class="px-4 py-5 sm:p-6">
            <x-maps-leaflet :centerPoint="['lat' => 52.16, 'long' => 5]"></x-maps-leaflet>
        </div>
    </div>
    

    The above html code is a part of the following livewire component that has the attached class.

    <?php
    
    namespace App\Http\Livewire\Modals;
    
    use LivewireUI\Modal\ModalComponent;
    
    class ViewMap extends ModalComponent
    {
        public function render()
        {
            return view('livewire.modals.view-map');
        }
    }
    

    I am able to use this component when not including it in a wire-element/modal but I am unsure why I get this error when attempting to load the map within the modal.

    Unhandled Promise Rejection: ReferenceError: Can't find variable: L
    
    image
    opened by ryangurn 4
  • Tiles

    Tiles

    Hi! What do I need to declare in the view to change the tile host? <x-maps-leaflet :tileHost="'http://c.tile.stamen.com/toner-labels/{z}/{x}/{y}.png'" :centerPoint="['lat' => $hotel->latitude-0.8, 'long' => $hotel->longitude]" :zoomLevel="9" :markers="[['lat' => $hotel->latitude, 'long' => $hotel->longitude]]"> This is what I'm doing at the moment, but all I get is a grey box.

    Thanks!

    enhancement 
    opened by CrisCrassus 4
  • Migrating from gonoware/laravel-maps / Javascript events available?

    Migrating from gonoware/laravel-maps / Javascript events available?

    Hey Lars,

    Thanks for trying to update gonoware/laravel-maps to PHP8 and for creating this repository. I'm currently trying to update one of my Laravel instances from version 8 to 9 and was forced away from gonoware/laravel-maps since there hasn't been any activity from the owner for over a year.

    After a bit of puzzling, I found that $markers[lng] in this repository has been changed to $markers[long]. However, I still haven't figured out if it is possible to hook into the Leaflet Map via Javascript events as it was possible in gonoware/laravel-maps. See this section of the readme for a reference.

    Is this something I have to look for in Leaflet.JS or does your code have possibilities for this as well? Thanks in advance!

    PS. Would you like me to create a Pull request for a little documentation for the migration from gonoware/laravel-maps to your repository? Or don't you think that's necessary?

    opened by RoelReijn 3
  • Livewire Uncaught (in promise) ReferenceError: L is not defined

    Livewire Uncaught (in promise) ReferenceError: L is not defined

    When including the component inside a livewire component with an @if tag, the component throws a Uncaught (in promise) ReferenceError: L is not defined in the console and fails to render the rest of the page.

    It works inside the livewire component if not inside an @if tag.

    I'm guessing this has to do with the order the scripts are loaded? Any help would be hugely appreciated. Thanks!

    question 
    opened by wazimshizm 3
Releases(v0.13)
  • v0.13(Dec 9, 2022)

    What's Changed

    • Changable attribution by @LarsWiegers in https://github.com/LarsWiegers/laravel-maps/pull/35
    • Better readme by @LarsWiegers in https://github.com/LarsWiegers/laravel-maps/pull/36
    • Support PHP 8.2 by @Xammie in https://github.com/LarsWiegers/laravel-maps/pull/37

    New Contributors

    • @Xammie made their first contribution in https://github.com/LarsWiegers/laravel-maps/pull/37

    Full Changelog: https://github.com/LarsWiegers/laravel-maps/compare/v0.12...v0.13

    Source code(tar.gz)
    Source code(zip)
  • v0.12(Apr 8, 2022)

    What's Changed

    • adding view publishing to readme by @ryangurn in https://github.com/LarsWiegers/laravel-maps/pull/30
    • reordering popup binding (fixing #27) by @ryangurn in https://github.com/LarsWiegers/laravel-maps/pull/31

    Full Changelog: https://github.com/LarsWiegers/laravel-maps/compare/v0.11...v0.12

    Source code(tar.gz)
    Source code(zip)
  • v0.11(Mar 23, 2022)

    What's Changed

    • Allow multile maps on screen (Leaflet only) by @LarsWiegers in https://github.com/LarsWiegers/laravel-maps/pull/29
    • allowing views to be publishable. by @ryangurn in https://github.com/LarsWiegers/laravel-maps/pull/26

    New Contributors

    • @ryangurn made their first contribution in https://github.com/LarsWiegers/laravel-maps/pull/26

    Full Changelog: https://github.com/LarsWiegers/laravel-maps/compare/v0.10...v0.11

    Source code(tar.gz)
    Source code(zip)
  • v0.10(Mar 10, 2022)

  • v0.9(Feb 14, 2022)

    What's Changed

    • Allow illuminate/support 9.0, needed if we want to upgrade to Laravel 9 by @fgaroby in https://github.com/LarsWiegers/laravel-maps/pull/22

    New Contributors

    • @fgaroby made their first contribution in https://github.com/LarsWiegers/laravel-maps/pull/22

    Full Changelog: https://github.com/LarsWiegers/laravel-maps/compare/v0.8...v0.9

    Source code(tar.gz)
    Source code(zip)
  • v0.8(Dec 31, 2021)

  • v0.7(Dec 30, 2021)

  • v0.6(Nov 8, 2021)

  • v0.5(Jul 2, 2021)

  • V0.4(Jun 30, 2021)

  • v0.3(Jun 22, 2021)

  • v0.1(May 26, 2021)

Prepare your Laravel apps incredibly fast, with various commands, services, facades and boilerplates.

Grafite Builder Grafite has archived this project and no longer supports or develops the code. We recommend using only as a source of ideas for your o

Grafite Inc 997 Dec 22, 2022
:computer: :octocat: A hackathon/MVP boilerplate for laravel web applications. Start your hackathons without hassle.

Laravel Hackathon Starter - SUSUMU 進 If you have attended any hackathons in the past, then you know how much time it takes to get a project started: d

Prosper Otemuyiwa 1.6k Dec 17, 2022
A package for adding loading spinners to your Laravel Artisan commands

Table of Contents Overview Installation Requirements Install the Package Usage Adding Loading Spinners to Commands Adding Text to the Spinner Customis

Ash Allen 9 Oct 19, 2022
Syntax-aware proofreading for your Laravel application.

Laravel Prose Linter Syntax-aware proofreading for your Laravel application. The Laravel Prose Linter helps you to polish the texts of your Laravel ap

Beyond Code 97 Dec 18, 2022
A Laravel admin panel which is creating CRUD for your application automatically.

Adds a zero configuration Admin Panel to your Laravel Application Installation You can install the package via composer: composer require max-hutschen

42coders 10 Aug 24, 2022
Initial template to start your awesome Laravel, Tailwind and Vue projects

Features Laravel 8.* Tailwind 2.1 Ready and Loaded @tailwindcss/typography @tailwindcss/forms Dark mode ready All variants enabled by default Vue 2, V

Marc Garcia Torrent 19 Jul 19, 2022
Allows to connect your `Laravel` Framework translation files with `Vue`.

Laravel Vue i18n laravel-vue-i18n is a Vue3 plugin that allows to connect your Laravel Framework JSON translation files with Vue. It uses the same log

Francisco Madeira 361 Jan 9, 2023
A boilerplate single php file for all your needs, no frameworks, no libraries.

SINGLE PHP FILE A boilerplate single php file for all your needs, no frameworks, no libraries. Avoid repetitive work It is a well known architecture d

null 15 Dec 30, 2022
A plugin to purge your unused assets, disabled products, and more.

Purge Assets for Craft CMS Purge Assets is a Craft plugin for super-simple purge of assets and products, either via the control panel or with console

Bram Beekman 4 Oct 10, 2021
A lightweight full-stack component layer that doesn't dictate your front-end framework

Airwire A lightweight full-stack component layer that doesn't dictate your front-end framework Demo Introduction Airwire is a thin layer between your

ARCHTECH 199 Nov 23, 2022
A package for building Admin-Interfaces that help maintaining the data of your applications

A package for building Admin-Interfaces that help maintaining the data of your applications. It provides an intuitive interface and the tools needed to manage your project's Users, Models and free Forms for Pages, Settings etc.

null 808 Dec 31, 2022
Wave - The Software as a Service Starter Kit, designed to help you build the SAAS of your dreams 🚀 💰

Introduction Wave is a Software as a Service Starter Kit that can help you build your next great idea ?? . Wave is built with Laravel, Voyager, Tailwi

null 4.2k Jan 4, 2023
ViMa, Open Sources make your business betters

NOTES Completed project will be upload after finish implementation & website will be can be access contain all information may be in September 21, 202

VM 49 Dec 25, 2022
Scaffolding to add some Mojo to your Drupal projects.

mojo-drupal-scaffold Scaffolding to add some Mojo to your Drupal projects. This package adds scaffolding files for your Drupal project by integrating

Bluehorn Digital 5 Mar 15, 2022
Symfony React Blank is a blank symfony and react project, use this template to start your app using Symfony as an backend api and React as a frontend library.

Symfony React Blank Symfony React Blank is a blank symfony and react project, use this template to start your app using Symfony as an backend api and

Antoine Kingue 2 Nov 5, 2021
Create Migration, Seed, Request, Controller, Model and Views for your resource (CRUD)

Table of Contents Laravel Resourceful NOTE! Usage Install through composer Add Service Provider Run it! Example Generated Controller Generated Views I

Remo 62 Aug 15, 2021
A skeleton for build your Kata with Docker

A skeleton for build your Kata with Docker

Raúl Coloma Bonifacio 1 Nov 12, 2021
An awesome starter template to create your Salla Apps today! 🚀

Salla Apps Starter Kit An awesome starter template to create your Salla Apps today! Explore our blogs » Report Bug · Request Feature . </Salla Develop

Salla 17 Dec 14, 2022