Hello, I need help in creating a location sensor that allows users to drop a pin on the map and have that location displayed in a label or text box. I've tried to find references for this but it seems that the available resources don't cover the topic of dropping location pins. Here's an example from the Uber app for reference.
Just to confirm, you want to place a marker on the map, based upon the device users current location?
If so, ensure you have at least one design time marker on the map (you can make it not visible), then from the users current location, create a new runtime marker with that location.
yes, but i don't know how to make user select the location from the map
Something like this, press the button to add a marker, which will only work if the location has changed:
Others may provide a better example.....
The LocationSensor does that for you. Follow Tim's example if you use the Map component; otherwise what you want to do depends on the map you want to use.
-
A Google Map - See Google Static Map Api, there is a way to 'drop a pin' to any location you want.
-
an App Inventor Map has a tool to determine the location of any point on the map the user touches. Code so that you add a pin using the coordinates that is provided by the tool. This is easy if you use Design time markers; doable also with Run time markers if you have the coding experience required.
or this might be useful tutorial for something similar Map It: Displaying Locations on a Google Map
Thank you for sharing these blocks. Could you please explain these blocks in more detail? I attempted to implement them but it didn't work as expected. What is the purpose of "Button1" in this context?
Thank you. I was able to successfully implement the location feature using the provided reference ("Map It: Displaying Locations on a Google Map 1").
However, it currently requires users to add a location first and then select it from a list. Is it possible for users to view a location by simply typing it into a textbox, without the need to add it first and then select it from a list?
As an example, it only sets a marker if button1 is pressed, and the location has changed.
Yes. You need to use one or two TextBoxes and a Button using location coordinates.
Something like this is what you might want
Add error control and you got it.
Yes you could also use a Text box only instead of the join block and type the street address instead of the latitude and longitude.