Home » Javascript » Different icon in leaflet map with 2 different object take in JSON file php

Different icon in leaflet map with 2 different object take in JSON file php

Posted by: admin August 19, 2018 Leave a comment

Questions:

I want render my marker that I get from my JSON file php. The json file is this

$risultato = array();
$query = "SELECT location.dataRilevazione AS data, 
location.lat AS latitudine, 
location.lon AS longitudine, 
mandria.nome AS nome, 
location.mandriaid AS numero
FROM location
JOIN mandria ON location.mandriaid = mandria.sim
WHERE dataRilevazione
BETWEEN '".$stringaInizio."'
AND '".$stringaFine."'
AND location.mandriaid IN (".$_GET[number].")
AND note = 'Rileviazione ordinaria'
ORDER BY nome, dataRilevazione ASC";

$result = mysqli_query($conn, $query);
$rowcount = mysqli_num_rows($result);

if ($rowcount == 0) {
echo "<br /><br /><br /><center><p>You have no locations in your database   for this period!</p></center>";
} else {
$i=0;
// Write the coordinates to a string
while ($line = mysqli_fetch_array($result, MYSQLI_ASSOC)) {
   $risultato[$i]['latitude'] = $line['latitudine'];
   $risultato[$i]['longitude'] = $line['longitudine'];
   $risultato[$i]['date'] = $line['data'];
   $risultato[$i]['title'] = $line['nome'];

   $i++;
}
}

//exit();
mysqli_close($conn);
echo json_encode($risultato);

I can have 2 different title because in clausle IN I can pass more parameters.
My question is: I want render a different icon marker for the first and for the last element that I get from the JSON file for each different title.
Example of this select is:
enter image description here
I hope I explained myself, can anyone help me?
Thank’s

Answers: