- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
因此,当新文档插入到 FSCollection 上时,我会创建标记,如下所示。
我有这个查找变量。
cordenadasClientes = Clientes.find({}, {fields:{'metadata.latCliente': 1,'metadata.longCliente':
跟随这个eachFunction。
var count = 0,
markers = [],
marker;
cordenadasClientes.forEach(function(){
var latitudCliente = cordenadasClientes[count].metadata.latCliente;
var longitudCliente = cordenadasClientes[count].metadata.longCliente;
var nombreCliente = cordenadasClientes[count].metadata.nombreCliente;
marker = new google.maps.Marker({
position: new google.maps.LatLng(latitudCliente ,longitudCliente),
map: map,
title: nombreCliente,
icon :'http://maps.google.com/mapfiles/marker_yellow.png',
})
count++;
markers.push(marker);
})
它的工作非常好,每次我在Clientes集合上创建一些文档时,都会插入一个标记,所以也有这个标记数组,所以每次都有一个新的标记已创建 markers.push(marker); 执行,这很好,但现在我正在尝试这样做
google.maps.event.addListener(markers, 'click', function() {
map.setZoom(8);
});
但不起作用,所以我想看看我的标记数组是什么样子,所以让这个其他功能;
function arrayMarkers(element,index,array){
console.log(markers);
}
并像这样调用arrayMarkers函数;
[markers].forEach(arrayMarkers);
并获取此 Console.log;
im the index : 0 and the object [object Object],[object Object]
所以我想在数组上创建标记 sostring,然后在事件监听器上使用该标记后,我做错了什么?,似乎事件监听器只在 1 个标记上工作
示例我有 2 个标记,因此当我单击 1 个标记时,它的缩放效果非常好,但是当我单击第二个标记时,它很快就会缩放到第一个标记
这就是我的标记数组的样子;[开,开]>0:开1:开
就像我将数组嵌套在数组上一样
如果我使用
function arrayMarkers(element,index,array){
console.log(array);
}
我明白了
[Array[2]]
>
0: Array[2]
>
0: On
1: On
最佳答案
通过创建此函数完成
//Added nombreCliente as parameter
function myInfoWindow(marker2,map,nombreCliente,telefonoCliente,ubicacionCliente,facebookCliente){
var infoWindow = new google.maps.InfoWindow();
google.maps.event.addListener(marker2, 'click', function() {
for(var i=0;i<cordenadasClientes.length;i++){
infoWindow.setContent( "Informacion Cliente : <br/>" + "Dale Pa: " + nombreCliente + "<br/> Telefononos: " + telefonoCliente + "<br/> Ubicado en: " + ubicacionCliente + "<br/> No olvides Pasarte Pa' su Facebook: ' " + '<a href="#' + facebookCliente + '">' );
infoWindow.open(map, marker2);
}});
}
并在markers.push之前调用它
myInfoWindow(marker2,map,nombreCliente,telefonoCliente,ubicacionCliente,facebookCliente);
关于javascript - 使用 FSCollection 创建标记,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27103382/
因此,当新文档插入到 FSCollection 上时,我会创建标记,如下所示。 我有这个查找变量。 cordenadasClientes = Clientes.find({}, {fields:{'m
当应用程序部署在 Meteor 服务器上时,我在上传 csv 文件时遇到一些问题。它可以在本地主机上运行。 我有这个错误: No 'Access-Control-Allow-Origin' heade
我是一名优秀的程序员,十分优秀!