How to search for nearest store

Hi, does anybody know how to set up a code that allows the user to search for the nearest store? For example, they would press a button and it will show them the nearest Walmart. Thanks!

@e_cho

You would need to include an Activity Starter Component, and give your search parametres. The app will then open Google Maps to display your query

blocks (1)

Hope this meets your requirement !

2 Likes

Screen Shot 2020-10-13 at 1.05.52 AM

Hi, thank you so much for responding!
This is my code on the right, but I tried it on an emulator and it says there is no action to be found. Could you tell me what might be wrong? Thank you.

Can u share your blocks?? and what have you entered in the Textbox1 ?

Try to use your cellphone

@e_cho

I have given u the snapshot of the COMPLETE CODE and the result of running it on emulator. The search criteria is shown on the google maps. So either u r missing out something in the rest of the code, or there is a conflict in code somewhere.

This code snippet works on the emulator used with App Inventor 2.

Use the + icon to zoom in to your location

Your Blocks might work.. make sure you have text in your TextBox.

This is on emulator too


With this ....
blocks (1)

@Anup_Ludra Sure, I changed up the code for it to correspond to a button, however I added a text box to make it like yours.

Screen Shot 2020-10-13 at 11.16.11 AM

@SteveJG
I tried the code you wrote as well, however it still shows me the error that there is no activity. Do you think it may be a problem within the emulator and my device? Or am I missing something, I really need this function.

Did you show all your Blocks? A guess is you may have a LocationSensor in your app or another component that cannot be used successfully in an emulator or using an emulator. Emulators emulate; they are not a real device and do not have the hardware necessary for lots of actions.

Did you test your app on a real device as was suggested by someone earlier? If not, try on a real device using Companion.

Ah yes, I had a location sensor in another screen. I deleted it and tried it on a Chromebook, and it does open up Google Maps, however it opens it up with nothing searched. I'll try to mess with it around and see if I can fix it. Thanks.

Success! Thanks to everybody that responded. I tweaked it a little and used a real device and it works! Sorry if I was a little slow, but I'm not an expert to this program. Once again, thank you.

Good !
Whatever suggestion worked out for you, kindly mark it as Solution and close the topic.

Having seen your blocks, and screen layout, you could make it simpler by having a spinner element giving all the options, or a textbox to take user requirement and do it with only 1 ActivityStarter, instead of a seperate Activity Starter for each search criterea and hardcoding the criterea, as you have done now.
Just a suggestion.
Good Luck

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.