Displaying Marker Coordinates (Lat & Long) in a Label on the Screen

Hi,

I'm trying to understand how I can place a marker anywhere on the map and display the latitude and longitude numbers in a label on the same screen of the app. I'm new to MIT App Inventor so don't know how to do too much yet.

Welcome Taran.

How to do this depends on how you intend to 'place' the Marker. You can place a Marker using the LocationSensor to show your present location or you can place a Marker using the Map.DoubleTapAtPoint Block by touching a spot on the Map where you want to see the Marker.

One way is to put a Label on the Designer and then put a Map component under it. Write code so that when your location changes the coordinates appear in the Label or whenever you touch the Map at a new spot.

The Block code for using the LocationSensor to place the Marker and show the coordinates is a bit different from using the DoubleTapAtPoint. What do you want to do?

Hi, thanks for the reply. I'm thinking of using the DoubleTapAtPoint. The only think I am confused with is how to constantly display the coordinates in the label everytime the marker (or DoubleTapAtPoint) location is changed.

Also is there a way to limit the number of decimal places of the coordinates(lat & long) which are displayed?

Try this

Alternative construction of Label with 2 decimal places.

The example Label value changes every time you doubletap.

Hi, I wanted to know if there is a way to load the map and where ever the marker is moved to the coordinates constanlty change, rather than double taping the screen to update the coordinates?

Just wondering if this is a possibility.

Sorry I do not understand what you mean. How do you expect to load the map. Please ask your question another way. It is possible to grab or drag the Marker and move it without 'tapping' the Map first. It is simple; use the last idea below. :wink:

perhaps you can experiment?

by adding the the Blocks in green might be what you want to do.

  • or use a TapAtPoint or LongPressAtPoint event handler instead

  • or use a LocationSensor

  • or
    dragMarker

Set Marker Property Draggable to true (use Marker Designer Property or the top dangling block in the image). When you run the code, long left click on Marker, let it popup. Drag Marker where you will, release Marker. All done :smile:

1 Like