简体   繁体   English

更改悬停 HTML 元素上的标记图标

[英]Change marker icon on hover HTML element

I would like to change the icon of a marker while hovering on a HTML element.我想在悬停在 HTML 元素上时更改标记的图标。 My markers are generated in a PHP array, which looks like this:我的标记是在一个 PHP 数组中生成的,如下所示:

$map_flats[] = array(
'title' => $price,
'image' => $file_name,
'type' => '',
'price' => $address,
'address' => $address,
'bedrooms' => $bedrooms,
'bathrooms' => $maxguests,
'area' => $area,
'position' => [
    'lat' => $lat,
    'lng' => $lng
],
'markerIcon' => 'marker-green.png'

);

I would like to change the 'marker-green.png' to 'marker-blue.png' while hovering a DIV.我想在悬停 DIV 时将“marker-green.png”更改为“marker-blue.png”。

ps.: the final result looks like this in js: ps:最终结果在js中是这样的:

var markers = [<?php echo json_encode($map_flats); ?>];

Could you tell me a possible way of doing that?你能告诉我一种可能的方法吗?

Thanks in advance,提前致谢,

Tibor蒂博尔

google provides a javascript function for this that is谷歌为此提供了一个 javascript 函数,即

marker_id.setIcon("marker_img"). marker_id.setIcon("marker_img")。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM