cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
MarcBailey
Resolver II
Resolver II

Multiple Map Pins onto a Google Map

I need help with code to add Multiple Map Pins onto a Google Map.

 

OnSelect will launch the Google Map outside of the PowerApps.

 

I am currently using the following code to launch Google Maps with the address of the selected item(Account) in BrowseGallery1 with the DataSource of AcctMain:

 

Launch("http://www.google.com/maps/search/?api=1&query="&Address1&City&State&PostalCode)

 

Now I need to launch Google Maps with the addresses of all items(Accounts) in BrowseGallery1 with the DataSource of AcctMain.

 

Any help would be greatly appreciated.  Thanks, Marc...

15 REPLIES 15
ericonline
Community Champion
Community Champion

Hi @BrianJ. Without getting into the code very deep...

  • How many items in your Collection = the ListBox.Selected.Result?
    • There might only be one. 

Keep hackin' you'll get it 🙂 

@ericonline

Ok I got this code working by clicking on the date in the List box.  But I would like foe a marker to show for each address that is in the list box.

 

"https://maps.googleapis.com/maps/api/staticmap?center=formatpng&markers=color:red%7C" & EncodeUrl(ListBox1_1.Selected.Result) & "&size=" & txtImageWidth & "x" & txtImageHeight & "&key=" & txtGoogleMapsKey.Text

I'm not real sure if a list box is my best option.  Attached is a screenshot of what I am working with.

Screen Shot 2018-12-30 at 11.02.48 PM.png

ericonline
Community Champion
Community Champion

Hi @BrianJ. Nice looking app!

Maybe try changing the ListBox out for a Gallery. Then try:

Filter(
        Inventory,
        Address exactin Gallery.AllItems.address
    ),

Where Gallery.AllItems.address is the text box in your gallery displaying the address.  You might have to use Gallery.AllItems.address.Text (or it might not work at all!). I'm more of a hands-on PowerApper. Its difficult for me to recall solutions without trying various things. 

Hope this helps!

@ericonline I changed to a Gallery and add your suggestion but I am now getting this error

"Invalid argument type (Table). Expecting a Text value instead."

 

Here is the code.

"https://maps.googleapis.com/maps/api/staticmap?center=formatpng&markers=color:red%7C" & EncodeUrl(Gallery1.AllItems.lblAddress) & "&size=" & txtImageWidth & "x" & txtImageHeight & "&key=" & txtGoogleMapsKey.Text
seadude
Memorable Member
Memorable Member

Hi @BrianJ. I had a few minutes to look at @luuminhvuong93's solution. His is different than what you're trying to do. He's filtering a Collection by something (say Agent Name in your case) and returning an array of Lat/Longs. I googled "multiple markers google maps by address". Of the two writeups I looked at, both are ALSO using Lat/Longs.

 

Example 1: https://nearplace.com/blog/how-to-add-multiple-markers-on-google-maps/

 

image.png

Example 2: https://www.taniarascia.com/google-maps-apis-for-multiple-locations/

You'll have to do some more research and see if its possible to pass Google Maps multiple Addresses at once or if you need to geocode them first (get Lat Longs) then supply the API those instead.

Good luck!

 

Hi,

I am looking for multiple pins with google o bing maps. I have find midle of a "solution" maybe you can help me.

I give you the solution for 1 pin with google maps and gallery

( i prefer google maps because the zoom work good. With bing the zoom in a static map its crazy)

 

My gallery have a item "Address" with a inputtext "Subtitle2_1 ".

I enter the Street, city .. like this : "7s9s Technology Way, Denver, co 80237"

 

In a picture :image: "https://maps.googleapis.com/maps/api/staticmap?center="
& Substitute(Subtitle2_1.Text; " "; "+") & "&zoom=5 &size=600x600 &key=MyKey &markers=color:red%7Clabel:A%7C" &(Subtitle2_1.Text)

 

This work.

 

For multiple pins:

If i use gallery.allitems.address not work

 

If i use this formula its ok : 

"https://maps.googleapis.com/maps/api/staticmap?center="
& "Brooklyn+Bridge;New+York;NY"
& "&zoom=13 &size=600x600 &key=MyKez
&markers=color:red%7Clabel:A%7C" &"Brooklyn+Bridge
&markers=color:red%7Clabel:A%7C" &"New+York;NY"

 

We need to separate the markers.

Now i am looking for automate the multiple marker.

I try to make a collection and the idea is to select each ID, ID=1, ID=2 with a formula who auto create the line "&markers=color:red%7Clabel:A%7C" &" " and complete with the resulte of the ID=x

But when i test with one markers to call the ID this dont work. 

Any idea?

I want to build the same that "mymaps" from google but with my own data directly in powerapps

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Power Apps June 2021

June Power Apps Community Call

Did you miss the call? Check out the recording here!

Top Solution Authors
Top Kudoed Authors
Users online (27,555)