Trying to show extra data related to a marker

Hi there,

I am working on an app that allows the user to click on a pin and this will display a column below with more information regarding the pinned location. The data is saved in a Cloud variable and will include the fields required to make up a pin and the additional info on click. I am struggling to bring these 2 elements together. When I click the pin it shows the final item in the list regardless of which pin I selected. I can’t seem to identify the correct ID from the marker to show the info.

I may be missing a fundamental concept with calling in data here and I really can’t work out what blocks to use to make this happen.

Thanks!
Ollie

1 Like

Hi there,

From what I can see, you cycle through the list PINS with the variable j.

When this is complete, j will be the final item of PINS.

You never reset j in the ‘onMarkerPress’ block, so the Label PinName will only display the data of the final item of PINS.

You can get the latitude and longitude of the marker that has been pressed using the event output from the ‘onMarkerPress’ block.

From there, you can set j to be the corresponding object from PINS, and display its data.

Here is a sample app that displays 3 markers on a map. If you click a marker, an image will appear. The image that appears depends on the marker that’s clicked.

Hope that helps!

Thank you so much for replying to me. I followed your instructions up to get getting the onMakerPress event created, which I can deffo see being the solution.

I get stuck here with my lack of knowledge, I see you are making a comparison in your example, but I don’t know how to go through the Cloud Variable and find the corresponding object based on the unique values in the Lat and Long, If you have time to point me in the right direction or share an example that would be amazing.

Thanks again!

Ollie

1 Like

It might be easier for you to make a new variable called ‘thisMarker’.

From the ‘onMarkerPress’ event, you will have a latitude and a longitude value. Store these as variables called ‘thisLat’ and ‘thisLong’.

You can use the ‘for each item j in list [cloud PINS]’ loop again.
This time, the blocks will say:
‘if (([get property “lat” of object j] = thisLat) AND (get [get property “long” of object j] = thisLong)), set thisMarker to j’.

Then you can use the same ‘from Label PinName set text’ block, except you will refer to thisMarker rather than j.

Hope that helps!

Jane

Hi Jane

That extra bit of detail really helped me and I got it working by following those additional instructions.
Thanks for taking the time to reply again, I feel like I can get back into it now that I am over this hurdle :smiley:

Cheers
Ollie

1 Like

I’m glad you found it helpful! :grinning:

I hope your app with info about locations is awesome :tada: