【发布时间】:2015-01-21 00:38:58
【问题描述】:
我评论了。我对这个库有疑问,因为这是我第一次使用它。花了几个小时寻找解决方案,但我没有找到。
我需要将鼠标悬停时的颜色更改为 X 颜色,并在没有鼠标悬停时返回原始颜色。
单击时更改为 Y 颜色并保持不变,直到您再次单击,鼠标悬停使其继续运行。
我一直被这个带有 svg 地图的例子指导:http://totaki.com/poesiabinaria/2014/10/crear-mapas-html5-interactivos-con-raphaeljs/
这是我的代码:
<link href="includes/css_includes/noticias_index.css" rel="stylesheet" type="text/css" />
<head>
<title>Ejemplo Raphaeljs</title>
<script type="text/javascript" src="includes/js_includes/jquery.min.js"></script>
<script type="text/javascript" src="includes/js_includes/raphael-min.js"></script>
</head>
<div class="contenido_noti">
<h1>RESULTADOS ELECCIONES 2012 - MUNICIPIOS</h1>
<center>
<table width="1180" border="0">
<tr>
<th scope="col">MAPA</th>
<th scope="col" style="text-align:center">ESTADISTICAS</th>
</tr>
<tr>
<th scope="col" width=""> <div id="lienzo">
</div></th>
<th scope="col" width="650" style="text-align:left">
<div id="municipiotxt"><img id="loadingicon" src="img_main/selecciona.png" /></div>
</th>
</tr>
</table>
</center>
<script>
var municipios_data = {
'ph1': 'Cadereyta de Montes',
'ph2': 'Jalpan de Serra',
'ph3': 'Colón',
'ph4': 'Querétaro',
'ph5': 'Pinal de Amoles',
'ph6': 'Arroyo Seco',
'ph7': 'Peñamiller',
'ph8': 'El Marqués',
'ph9': 'Tolimán',
'ph10': 'Landa de matamoros',
'ph11': 'Tequisquiapan',
'ph12': 'Pedro Escobedo',
'ph13': 'Ezequiel Montes',
'ph14': 'San Joaquín',
'ph15': 'Corregidora',
'ph16': 'Huimilpan',
'ph17': 'San Juan del Río',
'ph18': 'Amealco de Bonfil'};
var default_attributes = {
fill: '#999999',
stroke: '#000000',
'stroke-width': 1,
};
var $munictxt = $('#municipiotxt');
$.ajax({
url: 'includes/mapas/Mapa_muni.svg',
type: 'GET',
dataType: 'xml',
success: function(xml) {
var rjs = Raphael('lienzo', 570, 670);
var corr="";
$(xml).find('svg > g > path').each(function() {
var path = $(this).attr('d');
var pid = $(this).attr('id');
var pid_select="";
var munic = rjs.path(path);
munic.attr(default_attributes);
/*funcion de hover*/
munic.hover(function() {
this.animate({ fill: '#00bbff' });
}, /*funcion al moverso mouse*/ function() {
this.animate({ fill: default_attributes.fill});
}) /*funcion de click*/ .click(function() {
var muni_query=municipios_data[pid];
muni_select=pid;
$("#municipiotxt").load("includes/querys_includes/mapa_muni_SVG_QUERY.php",{muni_query:muni_query});
$munictxt.html(muni_select);
this.animate({ fill: '#FF0000' });
});
});
}
});
</script>
</div>
对不起,如果我的英语不好。
【问题讨论】:
标签: javascript jquery html svg raphael