jQuery ui地图交互从infoWindow/marker
jQuery ui map interaction from infoWindow/marker
我正在准备一个jQuery/谷歌地图列出所有的房子在我的数据库。一切正常。
现在我在标记信息窗口的内容中添加了一个DIV
,在鼠标移动时触发Style
背景色变化,在页面侧边栏中的房屋信息上列出了所有房屋。
gmap从<li data-gmapping='{"id":"30","latlng":{"lat": 40.161833,"lng":-7.943697},"tags":"drupal","desc":"mycontent"}'>
获取内容
我在里面插入"desc":
<div onmouseover='"highlight_id('.$ranking.')'" onmouseout='"highlight_id_x('.$ranking.')'">'.$name.'<br />More info soon!</div>
设法逃避括号'"
和我的DIV
使我想要的风格改变。有没有更好的方法把内容放在信息窗口里面?
地图jQuery代码:
$(function() {
$('#map_canvas').gmap({'disableDefaultUI':true, 'callback': function() {
var self = this;
$("[data-gmapping]").each(function(i,el) {
var data = $(el).data('gmapping');
self.addMarker({'id': data.id, 'tags':data.tags, 'position': new google.maps.LatLng(data.latlng.lat, data.latlng.lng), 'bounds':true }, function(map,marker) {
$(el).click(function() {
$(marker).triggerEvent('click');
});
}).click(function() {
self.openInfoWindow({ 'content': data.desc }, this);
});
});
}});
}).load();
问题:
- 如何在标记悬停上做同样的事情?如何/我们添加一个onmouseover javascript函数?
Ok!我现在明白了。
我正在使用一个jQuery插件谷歌地图(更多信息在这里)。
则在.click(function({self.openInfoWindow({ 'content': data.desc }, this);
之前添加.mouseover(function() {/*code*/})
}); '在我的例子中,改变地图外的DIV的背景
现在的总代码是:
$(function() {
$('#map_canvas').gmap({'disableDefaultUI':true, 'callback': function() {
var self = this;
$("[data-gmapping]").each(function(i,el) {
var data = $(el).data('gmapping');
self.addMarker({'id': data.id, 'tags':data.tags, 'position': new google.maps.LatLng(data.latlng.lat, data.latlng.lng), 'bounds':true },
function(map,marker) {
$(el).click(function() {
$(marker).triggerEvent('click');
});
})
.mouseover(function() {document.getElementById("rank_" + data.id).style.backgroundColor="#FFAAAA";})
.mouseout(function() {document.getElementById("rank_" + data.id).style.backgroundColor="#333333";})
.click(function() {
self.openInfoWindow({ 'content': data.desc }, this);
});
});
}});
}).load();
希望这对其他人有所帮助,现在我可以通过突出显示其div背景来查看我的gmap-marker与哪个项目相关
相关文章:
- geolocation-marker.js conflict with markerclusterer.js
- 边栏按钮和infoWindow是否可能有不同的内容
- 在for循环中使用多维数组设置google.maps.Marker图标
- 谷歌地图infowindow错误f=未定义的infowindow.js
- infoWindow在谷歌地图上的多个标记
- marker.setVisible(false) 和 marker.setMap(null) 不适用于所有标记
- jQuery无法在InfoWindow中处理表单
- 谷歌地图v3-将标记替换为infoWindow显示
- 使用json将infoWindow添加到映射标记中
- AngularJS的谷歌地图-点击标记时,InfoWindow没有设置在正确的位置
- 如何使infowindow和setzoom都适用于谷歌地图API v3
- 将信息框作为HTML标签属性(AngularJS)添加到Google Maps Marker
- 通过从下拉列表中选择来更新GoogleMaps InfoWindow
- Google Maps API - ControlPosition with Infowindow
- 我是否必须使用 google.maps.event.addListener(marker, 'click'
- 谷歌地图v3上的infoWindow不起作用
- marker.setMap(null);不起作用
- Angularjs 通过 infoWindow 动态设置过滤器变量
- 更改 L.layerGroup 中 L.Marker 的坐标
- jQuery ui地图交互从infoWindow/marker