Only slightly complicate the code in the previous post to allow viewing of two markers on which it is associated with the display of a text if you click on it.
The marker is displayed by the method map.addOverlay () , it is associated with the 'MouseClick event the occurrence of which will be processed according to the openSmartWindow .
follows the code that manages everything and of course, you will see the results by clicking here .
/ / Create the first
var marker = new marker1 YMarker (Italy Viale, 40, La Spezia, Italy);
/ / string to be displayed by clicking on first marker
contents1 var = "
I lived here from birth to 1990
"/ / Open a window when the event occurs 'click' on the marker
YEvent.Capture (marker1, EventsList.MouseClick,
function () {
marker1.openSmartWindow (contents1)
});
/ / Display the marker map.addOverlay
(marker1)
/ / Create the second
var marker = new marker2 YMarker ("Via Pontegrande 120, La Spezia, Italy ");
/ / string to be displayed by clicking on the second marker
contents2 var ="
I lived here from 1990 to 2000
"/ / Open a window when the event occurs 'click' sul marker
YEvent.Capture(marker2, EventsList.MouseClick,
function() {
marker2.openSmartWindow(contenuto2);
});
// Visualizza il marker
map.addOverlay(marker2);
Per semplicità mi sono limitato a ripetere per ogni marker i passi necessari alla loro visualizzazione. Volendo ricercare una soluzione più raffinata, avremmo potuto includere i dati da visualizzare in un array e visualizzare il tutto tramite un ciclo iterativo. Ma questo potrebbe essere oggetto di un ulteriore post.
Alla prossima.