Google map Places

Hi there I am trying to create an interface on top of anvil google map component like “google places” in standard google maps. I would like the

Below is what I would like the pop up to look like. However, I can’t figure out how to get the “on click” to pop up or how to populate an information window with the information from a data table.

  def load_map(self):
    
    for n in  self.my_assets_filtered:
      
      lat,lng = n['Location'].split(",")
      print(lat,lng)
      marker = GoogleMap.Marker(animation=GoogleMap.Animation.DROP,
                                position=GoogleMap.LatLng(lat,lng)        
        )
      self.map_1.add_component(marker)
      
1 Like

Hi @dp.nankivell,

Here’s an example that populates the InfoWindow with information stored in Data Tables:

https://anvil.works/build#clone:LGT2FYP34V4YOET5=GLRMCN4FR6L5YKOYE5BCTXMA

I used a separate Form to populate the InfoWindow, which should give you plenty of flexibility to create the layout you need (and it’s probably more fun than building it all in HTML, as per the docs :wink: )

1 Like

Awesome. Thx :man_dancing:

Thanks, @bridget
that’s very helpful and clear it up for me.
As these places are known the addresses is there a way to pull the data from google places ?

Hi @dp.nankivell,

You can look up addresses from locations, and vice-versa, using the GoogleMap.geocode function.

If you’re after more detailed information, the Places API looks like the way to go. Sounds like you’re on the right track with your package request :slight_smile:

Googlemaps Python package - #2