Problema tra la mappa e il marker (to change Marker color using a ListPicker)

Salve a tutti,
tramite la funzione Map1.PanTo vado a specificare la latitudine e la longitudine alla mappa, del marker specifico. Come mai il FillColor del marker non funziona?


Saluti
Nicola

A guess is move the FillColor Block before the Map1.PanTo Block.

fillcolor

Ho provato a seguire il tuo consiglio..ma non funziona :thinking:

"I tried to follow your advice..but it doesn't work"

What does not work? The recommendation is

recommendation

to place the block immediately preceding the Map1.PanTo Block. What you coded would change the color to yellow after every selection.

Your issue possibly occurs :

  • because you use the PanTo Block. Sometimes this Block produces strange results. Instead of PanTo try using

insteadOfPanTo

  • or you have issues with the ListPicker ? ListViewer ?

  • other guesses are impossible because you do not show all the code in your 'picker' Block.

Have you tried this code in a Button?

fillcolor2 . It works every time. :slight_smile:

  1. Ho provato a spostare il blocco Autostrade.FillColor dopo il blocco LPAutostrade.SelectionIndex; ma ugualmente non funziona.
  2. Inoltre ho anche provato a sostituire il blocco Map1.PanTo, con il blocco Map1.CenterFromString; ma ugualmente non funziona.

Alla fine ho risolto in questo modo:

You didn't solve the Problem :cry: , you substituted a CustomMarker instead of changing the default Marker color.

re: LPAutostrade.SelectionIndex block; but it still doesn't work.
I also tried replacing the Map1.PanTo block with the Map1.CenterFromString block; but it still doesn't work.
I finally solved it like this:

ImageAsset Specifies the image shown for the Marker. If set to the empty string “”, then the default marker icon will be used.

Well, as long as you are happy.

3 Likes

SteveJG hai perfettamente ragione sul fatto che in realtĂ  non ho risolto il problema; ma ho cercato di aggirarlo con un'alternativa; utilizzando la funzione ImageAsset :pensive:

This code works on my tablet Android 8.1. The code might help you get a Marker to change color as you originally attempted.

thisCodeWorks

If Autostrada_1 is selected, the Marker changes color to yellow and moves to the new lat/lon. If Austostrada_2 is selected, the Autostrada_2 Marker changes to green.

You need to set Autostrada_A1,Autostrada_2 using ElementsFromString.
The code uses a ListPicker.ElementsFromString set to Autostrada_A1,Autostrada_2

Purtroppo neppure questa è una soluzione, dato che sia se clicco su Autostrada_A1 e sia su Autostrada_A2; FillColor deve risultare comunque di colore giallo.

Unfortunately, this is not a solution either, since both if I click on Autostrada_A1 and on Autostrada_A2; FillColor must still be yellow in color.

I do not have any idea what you want to do Nicola. What .. FillColor deve risultare comunque di colore giallo . The code changes the Autostrada_A1 Marker to yellow if Autostrada_A1 is selected and as an example changes Autostrada_A2 Marker to green if it is the second item in the ListPicker. Selecting the second index will not change the color of Autostradad_A1 Marker Using Programming Your App to Make Decisions advice, you can make the code do anything you want it to do. The code is an example; experiment it and make similar code to do what you want it to do in your app. Are you sure you copied the code correctly?

In pratica ogni volta che l'utente sceglie un'autostrada dall'elenco; solo quel marker deve risultare giallo; per far si che venga risaltato all'interno di tutti gli altri.

Ok, that is possible. You do not share all your code so I or no one can provide additional advice.
You need code (possibly a Procedure) to set all your Markers back to their original color prior to commanding the color for a particular highway set to yellow. Modify the code snippet provided in post #8 ; adjust to your requirements and you can achieve your goal.

Hai perfettamente ragione sul fatto che non mi puoi aiutare se non ti mando tutto il codice.
Quindi te lo mando subito :wink:

might be what you hope to do. The example will clear the yellow from all the Markers and make the Marker yellow for the SelectionIndex yellow.

There are many ways to do this; use either resetMarkerColor (in which case you have to provide a List of Markers) or the alternativeRestartMarkerColor Procedure Blocks.

You could also reduce the number of if..then else Blocks but what you have will work. For instance code similar to this example will eliminate all these if..then Blocks.

Good luck.

2 Likes

@SteveJG grazie per il tuo preziosissimo aiuto; seguirò i tuoi consigli.
Saluti
Nicola

1 Like

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