esadewater / livewire-maps

Basic Google Maps-implementation for Laravel-Livewire currently supporting map-markers and map-move-listeners.
MIT License
16 stars 2 forks source link

the map is not displayed #7

Closed pixsolution closed 1 year ago

pixsolution commented 1 year ago

Hello! I followed the steps you indicate for Installation and Usage but the map is not displayed. I have already tried with 2 api keys and nothing, and it is not the api key because I am using one of them in another project and it works. What can be?

I'm using in my local project: "php": "^8.0.2", "laravel/framework": "^9.19", "laravel/jetstream": "^2.12", "livewire/livewire": "^2.5",

esadewater commented 1 year ago

Hi there, I'm sorry to hear that you weren't able to get it up'n'running with the provided docs. I'm not sure about the reason but I will take a look into it later today and maybe I will make an example project. Cheers, Erik

esadewater commented 1 year ago

Ok, so reviewed the process of getting this package up'n'running. I found a few things that definitely could and should be made easier, but as the release of Livewire v3 might right around the corner I limited the improvements to the docs. The basic steps are:

  1. Install composer package esadewater/livewire-maps
  2. Install nem package @googlemaps/markerclusterer (added this step)
  3. Import the init function in your app.js and call it afterwards (updated this step)
  4. Add the @livewireMapsScripts directive after the app.js and @livewireScripts

I made a sample project to demonstrate these steps: https://github.com/esadewater/livewire-maps-sample

I hope I could help you with this! Cheers, Erik

pixsolution commented 1 year ago

Hi @esadewater thanks, I tried those steps but nothing yet.

My app.js

import './bootstrap';

import Alpine from 'alpinejs';
import focus from '@alpinejs/focus';
import { init } from "../../vendor/esadewater/livewire-maps/resources/js/LiveWireMaps";
window.Alpine = Alpine;

Alpine.plugin(focus);

Alpine.start();

init();

after modified app.js I runned npm run dev

in my layouts/app:

<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <meta name="csrf-token" content="{{ csrf_token() }}">

        <title>{{ config('app.name', 'Laravel') }}</title>

        <!-- Fonts -->
        <link rel="stylesheet" href="https://fonts.bunny.net/css2?family=Nunito:wght@400;600;700&display=swap">

        <!-- Scripts -->
        @vite(['resources/css/app.css', 'resources/js/app.js'])

        <!-- Styles -->
        @livewireStyles
    </head>
    <body class="font-sans antialiased">
        <x-jet-banner />

        <div class="min-h-screen bg-gray-100">
            @livewire('navigation-menu')

            <!-- Page Heading -->
            @if (isset($header))
                <header class="bg-white shadow">
                    <div class="max-w-7xl mx-auto py-6 px-4 sm:px-6 lg:px-8">
                        {{ $header }}
                    </div>
                </header>
            @endif

            <!-- Page Content -->
            <main>
                {{ $slot }}
            </main>
        </div>

        @stack('modals')

        @livewireScripts
        @livewireMapsScripts()
    </body>
</html>

in another view I put your component:

<livewire:map-view center-lat="52.004021" center-lng="7.710472" zoom="3" style="100vh" />

also tried as you put it:

<div style="height: 100vh; width: 100vw">
    <livewire:map-view />
</div>

my browser console: 1

any clue what it could be?

Regards

esadewater commented 1 year ago

Hmm, the browser console looks good. Did you compile the resources with e.g. npm run dev? If so, does my sample app work for you?

Erik

tiagofcp commented 1 year ago

its happens when you use alpinejs that is comon to have together with livewire

esadewater commented 1 year ago

Ok, that's possible. Do you know if there is a general problem with Alpine + GMaps, or is it specific to this package? This package was kind of a proof of concept for me, but I'll look into it, also in light of the fact that Alpine may become a core dependency of the upcoming LWv3

tiagofcp commented 1 year ago

Maybe you will need to load the gmaps with alpine js instead of native js