Google Map API v2 - GeoCoder - 如何自定义标记?
我尝试使用这种方式(示例)使用 Gmap V2 添加/自定义标记:
for (var i in table)
{
var myvar = table[i]['text'] ;
var myaddress = table[i]['address'] ;
geocoder.getLatLng(
myaddress ,
function(point) {
alert(myvar) ; // here myvar is wrong
// ... adding customer markers ...
}
});
}
在这个示例中,我得到了表中每个条目的优点,但 myvar 是错误的,在每个调用中:myvar 保持等于最后一个条目表...
geocoder.getLatLng 是异步函数,是因为这个吗?
编辑: 谢谢你的回复。但当我使用循环时,我就遇到了这个问题:
var address = 'somewhere';
for (i = 0 ; i < 3 ; i++)
{
geocoder.getLatLng(
address,
function(point) {
if (point) {
alert(i);
}
});
}
点总是等于 3!
I try to add/customize markers with Gmap V2 by using this way (example) :
for (var i in table)
{
var myvar = table[i]['text'] ;
var myaddress = table[i]['address'] ;
geocoder.getLatLng(
myaddress ,
function(point) {
alert(myvar) ; // here myvar is wrong
// ... adding customer markers ...
}
});
}
In this sample I got the good point for each entry in the table, but myvar is wrong, in each calls : myvar stay equal to the last entry of the table...
geocoder.getLatLng is asynchronous function, is due to that ?
Edit:
Thanks for you reply. But I just have that issue when I use a loop for example :
var address = 'somewhere';
for (i = 0 ; i < 3 ; i++)
{
geocoder.getLatLng(
address,
function(point) {
if (point) {
alert(i);
}
});
}
Point always equal to 3 !
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这就是我所做的。
如果这没有帮助你可以看看:
http://code.google.com/intl /da/apis/maps/documentation/javascript/overlays.html#Icons
here is what i do.
If this is not helping you can take a look at:
http://code.google.com/intl/da/apis/maps/documentation/javascript/overlays.html#Icons
自动解决:
Autosolved :