Skip to content

[Map] Google map ID config when using a marker #2306

Closed
@Nayte91

Description

@Nayte91

Hi there,

I'm playing around with UX map with my Google account, and while I'm following a simple example from doc, I get an unexpected behavior;

#[Route('/event/{id}', name: 'app_test')]
public function test(EventETT $event): Response
{
        $point = new Point(48.858370, 2.294481);

        $map = (new Map('default'))
            ->zoom(10)
            ->addMarker(new Marker($point))
            ->center($point)
        ;

        return $this->render('skeletons/event/show.html.twig', [
            'event' => $event,
            'map' => $map
        ]);
}

I think this is a very simple example based on docs, if I didn't made any mistake, I get the following behavior:

image

Google Maps can't load correctly on this page. in the canvas, and The map is being initialized without a valid map ID, which prevents the use of advanced markers. Well, OK, let's do this; I created a map ID on my cloud console, and then... I don't really know how to load it in my app. Here's the official doc about it.

So here I am: did I made a mistake if I get stuck like this? If so, can I improve the doc to help future devs to not get stuck as me? If I didn't made a mistake, is there an elegant, already provided way to add this map ID? I expect a en variable the same way than GOOGLE_MAPS_API_KEY but where to mix them up to create the final url with map ID? I suppose it's related to UX_MAP_DSN but before going deeper and maybe propose an update here, I prefer asking here, because it's a veeery basic step where I'm stuck, so I wonder if there is an already implemented way of dealing with this. And if so, I would add it to the doc!

Metadata

Metadata

Assignees

No one assigned

    Labels

    MapRFCdocsImprovements or additions to documentation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions