gpt4 book ai didi

javascript - 我如何使用 MarkerWithLabel 中的 labelContent 访问值,它们之间有空间

转载 作者:行者123 更新时间:2023-12-03 12:19:32 24 4
gpt4 key购买 nike

当我从谷歌地图 API 中的 json 数据访问值并在 MarkerWithLabel、labelContent:building.Post-completion 的帮助下添加标记时。但是当我运行此代码时,它显示,ReferenceError: 完成未定义,但我的 json 数据具有以下类型。我认为 Post-completion 中的 - 字符存在问题,它无法读取单个句子。但有一个与之关联的值。

  var activity_status = [{"Completion": 0, "Pipeline": 0,  "Implementation": 5, "country": "MYANMAR", "Post-completion": 138, "Cancelled": 0},
{"Completion": 0, "Pipeline": 0, "Implementation": 0, "country": "Bahrain", "Post-completion": 0, "Cancelled": 0},
{"Completion": 0, "Pipeline": 0, "Implementation": 0, "country": "ZIMBABWE", "Post-completion": 1, "Cancelled": 0},
{"Completion": 0, "Pipeline": 0, "Implementation": 12, "country": "MONGOLIA", "Post-completion": 34, "Cancelled": 0},{}];






for(var j= 0; j < activity_status.length; j++) {
(function(i) {
var building = activity_status[i];

geocoder.geocode({'address':building.country}, function(results,status){

if(status == google.maps.GeocoderStatus.OK){
var marker = new MarkerWithLabel({
position:new google.maps.LatLng(results[0].geometry.location.lat(),results[0].geometry.location.lng()),
title:building.country,

map:map,
labelContent:building.Post-completion,
labelAnchor:new google.maps.Point(6,22),
labelClass:"labels",
labelInBackground:false,
icon:"circle2.png"
});
console.log(building.country)
}
else{
console.log("Geocode was not succcessful for the following reason:" + status);
}
});
})(j);

最佳答案

像访问数组一样访问它。 建筑['竣工后']

关于javascript - 我如何使用 MarkerWithLabel 中的 labelContent 访问值,它们之间有空间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24509258/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com