dynamic marker icon and color
paskuale75 opened this issue · 1 comments
paskuale75 commented
Can I set a hexadecimal color attribute for markers ?
As here ...
thanks
paskuale75 commented
[solved]
foreach ($places as $s) {
$_coord = new LatLng(['lat' => $s->latitudine, 'lng' => $s->longitudine]);
$fillColor = ArrayHelper::getValue($s, 'tipo.colore','#E32831');
$icon = [
'path'=> "M27.648-41.399q0-3.816-2.7-6.516t-6.516-2.7-6.516 2.7-2.7 6.516 2.7 6.516 6.516 2.7 6.516-2.7 2.7-6.516zm9.216 0q0 3.924-1.188 6.444l-13.104 27.864q-.576 1.188-1.71 1.872t-2.43.684-2.43-.684-1.674-1.872l-13.14-27.864q-1.188-2.52-1.188-6.444 0-7.632 5.4-13.032t13.032-5.4 13.032 5.4 5.4 13.032z",
'fillColor'=> $fillColor,
'fillOpacity'=> 1,
'strokeWeight'=> 0.5,
'scale'=> 0.65
];
// Lets add a marker now
$marker = new Marker([
'position' => $_coord,
'title' => $s->address,
'icon' => json_encode($icon)
]);
// Provide a shared InfoWindow to the marker
$marker->attachInfoWindow(
new InfoWindow([
'content' => '<p>' . $s->address . '</p>'
])
);
// Add marker to the map
$map->addOverlay($marker);
}