2

I have a lightning-map component in my LWC component.

I hide the list of markers as I do not like what the component has and provide my own.

If user clicks on a marker in the map, I can handle and scroll my list appopriately through onmarkerselect.

However, there does not seem to be a way to programmatically select a marker. Setting selected-marker-value={currentMarkerValue} has no effected on the map. To be precise, the expectation is that the info window (gmaps term) aka the little bubble pop up should show up.

Update This is specifically when map is declared with list-view="hidden" attribute

14
  • My initial interpretation was that you have custom implementation of marker list that required a programmatic selection and I posted the answer on those lines. Clearly that's not the expectation and hence, deleted my answer. I've added your comment to this question to make it a bit more precise (hope you don't mind).
    – arut
    Sep 21, 2020 at 8:38
  • 1
    Custom implementation of marker list - this is exactly what i have. I hide their default list since I can’t customise it’s appearance and make my own list. I want just like withtheir list - if user clicks an item, the popup should open
    – zaitsman
    Sep 21, 2020 at 8:39
  • Short answer: Not possible with the base component.
    – arut
    Sep 21, 2020 at 9:39
  • Under the hood, lightning-map uses a whole lot of google maps APIs and private lightning base components which facilitate the various functions (including the pop-up info). Default marker list is based on lightning-primitive-coordinate-item (each entry in the list corresponds to one component) and each entry gets a GUID (which will be same as the GUID of corresponding map marker). When you click on an item, a custom event is dispatched (with this GUID in detail attribute) and the maps APIs invoke the event handler to display pop-up.
    – arut
    Sep 21, 2020 at 9:49
  • The click event that displays the info occurs much earlier in the chain of events and markerselect event is the last one in this chain. The sole purpose of markerselect event seems to be able to fetch the selected marker value and use it. Since, you can't programmatically hack into the shadow DOM, you can't get the marker GUIDs and invoke the specific click event. The click event in your custom list implementation bypasses all the internal events and hence, no pop-up.
    – arut
    Sep 21, 2020 at 9:56

0

You must log in to answer this question.

Browse other questions tagged .