目前我在数据库中拥有lat长值的#759。我必须在运行时从数据库中获取这些数据并从中创建热图。当我执行此代码时,我得到以下输出
我的代码是
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Heatmaps</title>
<style>
html, body, #map-canvas {
height: 100%;
margin: 0px;
padding: 0px
}
#panel {
position: absolute;
top: 5px;
left: 50%;
margin-left: -180px;
z-index: 5;
background-color: #fff;
padding: 5px;
border: 1px solid #999;
}
</style>
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&signed_in=true&libraries=visualization"></script>
<script src="https://code.jquery.com/jquery-1.11.3.min.js"></script>
<script type="text/javascript">
// Adding 500 Data Points
var map, pointarray, heatmap;
var latlng = jQuery.parseJSON('{"22.396428,114.109497": "1","37.368595,-121.92018": "1","37.369366,-121.92077": "1","37.626827,-79.58193": "1","37.61383,-79.59316": "1","37.61173,-79.59856": "1","37.61153,-79.601425": "1","37.6039,-79.62361": "1","37.610302,-79.61913": "1","37.5623,-79.68936": "1","37.51617,-79.67629": "1","37.147198,-80.342834": "1","37.146343,-80.34469": "1","12.996512,77.542616": "1","37.3931158,-121.9105196": "1","19.1199982,72.88999557": "1","15.526964,73.832266": "1","19.068611,73.000275": "1","19.068611,72.99917": "1","28.534723,77.179348": "1","28.543463,77.14846": "1","28.6139391,77.2090212": "1","37.3729489,-121.92731119999999": "1","37.368694,-121.92026": "1","37.368057,-121.91978": "1","40.001724,-75.26075": "1","37.201504,-121.844444": "1","18.5204303,73.8567437": "1","28.581147,77.37131": "1","34.162033,-118.46924": "1","34.17249,-118.46296": "1","28.599445,77.31944": "1","34.086544,-118.376837": "1","37.369095,-121.92056": "1","28.6,77.31778": "1","13.011879,80.2463": "1","28.525278,77.15639": "1","28.551945,77.18445": "1","28.556667,77.18389": "1","28.550195,77.183148": "1","13.002537,80.252701": "1","12.985096,80.256017": "1","28.585278,77.38528": "1","28.518612,77.16028": "1","28.520039,77.155694": "1","28.519444,77.16": "1","28.534469,77.172232": "1","13.011879,80.246302": "1","28.533999,77.171762": "1","28.533566,77.16436": "1","12.9975,80.25694": "1","13.0826802,80.2707184": "1","28.599167,77.31944": "1","28.533623,77.216471": "1","28.4594965,77.0266383": "1","37.368965,-121.92046": "1","37.3712051,-121.93588469999999": "1","37.368725,-121.92028": "1","37.3931158,-121.9089532": "1","37.45195,-122.16384": "1","37.452274,-122.1642": "1","28.579445,77.36833": "1","28.599445,77.31917": "1","28.5355161,77.3910265": "1","19.130833,72.929726": "1","28.586433,77.373169": "1","19.219991,72.85115719": "1","28.3999908,76.95997953": "1","37.379154,-121.95404": "1","37.41158,-122.07297": "1","37.4089,-122.03068": "1","35.935482,-119.43126": "1","35.163483,-113.73013": "1","29.559166,106.57222": "1","13.045117,80.201572": "1","35.86166,104.195397": "1","13.037791,80.184071": "1","29.557540099999997,106.55155029999999": "1","38.936134,-77.3591": "1","38.93623,-77.35895": "1","42.25568,-88.200998": "1","42.255637,-88.201008": "1","41.04895,-74.06878": "1","38.936142,-77.36655": "1","37.3711942,-121.9359197": "1","28.565556,77.1925": "1","31.2399995,121.4832544": "1","40.00569,-75.28456": "1","28.534109,77.171988": "1","28.53908,77.149813": "1","12.993617,80.255297": "1","12.993207,77.542303": "1","28.586433,77.37317": "1","28.581048,77.371495": "1","20.593684,78.96288": "1","19.178612,72.88194": "1","37.3711893,-121.9359317": "1","28.362457,-81.49357": "1","28.534037,77.172142": "1","28.533587,77.171692": "1","37.371186699999996,-121.9359355": "1","37.368458,-121.92008": "1","33.93866,-118.38314": "1","28.362385,-81.49357": "1","27.7599943,76.95997953": "1","23.634501,-102.552784": "1","37.372950599999996,-121.92731450000001": "1","37.369675,-121.921": "1","38.936413,-77.36633": "1","38.921117,-77.235705": "1","37.3711785,-121.9359848": "1","37.369404,-121.9208": "1","28.599722,77.31917": "1","28.630947,77.375348": "1","18.998611,72.83139": "1","37.372602,-121.91833": "1","55.378051,-3.435973": "1","51.6599894,0.6325936317": "1","40.7383172,-73.9936039": "1","40.735638,-74.00143": "1","28.45929,77.049077": "1","28.462461,77.056856": "1","40.7452962,-73.9888126": "1","40.75713,-73.99415": "1","37.36972,-121.92361": "1","33.770096,-84.390594": "1","38.93624,-77.36646": "1","37.364006,-121.924850": "1","28.496666,77.08972": "1","28.527844,77.170462": "1","37.368866,-121.92039": "1","37.368828,-121.92036": "1","37.360588,-121.923439": "1","41.87194,12.56738": "1","37.370916199999996,-121.9357719": "1","28.584906,77.292067": "1","28.623173,77.369955": "1","17.426665,78.445295": "1","52.0372651,-0.7665951999999999": "1","37.3693728,-121.9230723": "1","12.997778,80.25694": "1","1.3113889,80.22222": "1","37.3689926,-121.92321019999999": "1","1.3155556,80.22667": "1","28.495277,77.08972": "1","28.528404,77.170399": "1","28.438612,28.4375": "1","28.58423,77.364152": "1","19.06639,72.824165": "1","19.066668,72.82389": "1","19.066944,72.824165": "1","19.064722,72.824165": "1","28.623523,77.370305": "1","28.546811,77.180526": "1","28.643281,77.382196": "1","36.1062,-115.17771": "1","38.937611,-77.373711": "1","37.3382082,-121.8863286": "1","37.370604799999995,-121.9356358": "1","37.367954,-121.9197": "1","40.46366700000001,-3.74922": "1","28.502952,77.416394": "1","51.165691,10.451526": "1","41.3850639,2.1734035": "1","37.3689922,-121.92320799999999": "1","37.368761,-121.927922": "1","28.506707,77.418222": "1","28.520315,77.167035": "1","37.3705938,-121.93566750000001": "1","37.369473,-121.92085": "1","-26.1200058,28.10997963": "1","37.3705913,-121.9356701": "1","37.20185,-121.84451": "1","28.424595,77.012866": "1","28.456482,77.057078": "1","37.3729545,-121.9273348": "1","37.368991699999995,-121.92320699999998": "1","18.555,73.806946": "1","18.556944,73.80666": "1","18.553612,73.81084": "1","28.519167,77.20194": "1","28.526112,77.157776": "1","28.529481,77.169854": "1","33.79995,-117.886": "1","37.368996,-121.92049": "1","28.5975,77.3175": "1","28.525278,77.15667": "1","28.515278,77.08945": "1","28.511511,77.420652": "1","28.600277,77.318886": "1","28.578888,77.36833": "1","19.129723,72.930275": "1","28.579166,77.36833": "1","19.083334,73.00445": "1","19.096666,72.85389": "1","28.426638,77.012786": "1","28.517928,77.424019": "1","38.936584,-77.37398": "1","37.3687398,-121.9226432": "1","37.3708684,-121.93598130000001": "1","37.38592,-122.04978": "1","37.369137,-121.92059": "1","37.368992,-121.9232079": "1","37.201736,-121.8443": "1","28.525833,77.155556": "1","28.531433,77.170709": "1","19.155834,72.85555": "1","28.524445,77.15444": "1","28.530983,77.170259": "1","37.3689921,-121.9232079": "1","23.5999954,58.20636034": "1","19.0599918,73.00882816": "1","19.0575,72.854164": "1","40.31456,-74.661316": "1","38.936573,-77.373955": "1","38.91591,-77.22287": "1","38.914528,-77.22044": "1","39.04956,-77.11567": "1","49.4799972,-121.2700081": "1","37.6799941,-121.6828537": "1","37.408356,-121.921524": "1","19.103936,72.899171": "1","47.580064,-122.165008": "1","23.035278,72.5225": "1","26.8824935,80.93063593": "1","37.36802,-121.91975": "1","37.372913,-121.91765": "1","42.101025,-87.88506": "1","42.101173,-87.88561": "1","6.931608199999999,79.84533139999999": "1","7.873053999999999,80.77179699999999": "1","37.369537,-121.9209": "1","39.808872,-75.4671": "1","19.0199947,72.85113573": "1","28.536616,77.172181": "1","28.575326,77.227677": "1","38.937702,-77.373672": "1","32.72649,-117.193695": "1","37.373933099999995,-121.91773889999999": "1","37.37881,-122.13524": "1","49.1992557,-2.12467432": "1","32.72702,-117.19605": "1","32.72704,-117.19613": "1","37.394371,-121.9959855": "1","37.378754,-122.03416": "1","37.36861,-121.92027": "1","36.121784,-115.17634": "1","33.655594,-117.990364": "1","56.130366,-106.346771": "1","33.65651,-117.990364": "1","33.655834,-117.990364": "1","36.121677,-115.17634": "1","36.120884,-115.17634": "1","-25.274398,133.775136": "1","36.11145,-115.17874": "1","36.12147,-115.17634": "1","38.93643,-77.36633": "1","37.329483,-121.90155": "1","37.404465,-121.937004": "1","37.411663,-121.92754": "1","39.74745,-75.54912": "1","40.70702,-74.56588": "1","37.3689957,-121.92320339999998": "1","-38.416097,-63.61667199999999": "1","37.393166,-121.982216": "1","37.393127,-121.98113": "1","40.72888,-74.39627": "1","40.7329,-74.27761": "1","40.70277,-74.01343": "1","40.44361,-73.39167": "1","28.522403,77.419202": "1","17.459883,78.335531": "1","17.427301,78.338867": "1","17.423294,78.332237": "1","37.368080,-121.922394": "1","37.3683,-121.93182": "1","37.367916,-121.91967": "1","24.64927,-81.56319": "1","37.4599993,-122.1996832": "1","37.459057,-122.17655": "1","37.3689939,-121.92320059999999": "1","37.388268,-121.95726": "1","15.928786,73.91427": "1","37.451374,-122.15675": "1","18.9556217,72.80950785": "1","18.952648,72.817492": "1","37.368935,-121.92044": "1","3.13999772,101.6699266": "1","37.795837,-122.39747": "1","37.3689916,-121.92320079999999": "1","37.09024,-95.712891": "1","28.536564,77.211101": "1","-1.28000379,36.82999134": "1","-1.28000379,36.76999569": "1","28.558053,77.352318": "1","33.013844,-96.751366": "1","28.547118,77.198563": "1","23.424076,53.847818": "1","19.06776,72.84071": "1","19.109339,72.826454": "1","28.535717,77.169779": "1","38.937622,-77.373703": "1","37.36980699,-121.92395507": "1","37.3698051,-121.923399": "1","37.369064,-121.92054": "1","28.530975,77.157954": "1","37.370159,-121.923141": "1","37.369862,-121.923584": "1","28.49781,77.088103": "1","34.458199,-119.252838": "1","34.458149,-119.252823": "1","37.368088,-121.9198": "1","19.11474,72.89438": "1","19.1799939,73.07348013": "1","37.369576,-121.923912": "1","37.369507,-121.923965": "1","37.369709,-121.923439": "1","37.369728,-121.923737": "1","37.369705,-121.923615": "1","37.369740,-121.923622": "1","37.369728,-121.923637": "1","37.86304826,-122.25449793": "1","37.369793,-121.923653": "1","37.86691004,-122.26024775": "1","37.86324181,-122.25455553": "1","37.369675,-121.923836": "1","37.367222,-121.921326": "1","37.796688,-122.39747": "1","37.796574,-122.39747": "1","37.79696,-122.39747": "1","37.201576,-121.84426": "1","37.20185,-121.84432": "1","37.365135,-121.920868": "1","38.937595,-77.373672": "1","37.201077,-121.84436": "1","38.937759,-77.373825": "1","38.937687,-77.373650": "1","37.86312428,-122.25464788": "1","38.939968,-77.374428": "1","38.937725,-77.373634": "1","38.937721,-77.373642": "1","38.937748,-77.373611": "1","38.937748,-77.373604": "1","37.369789,-121.923592": "1","37.369812,-121.923607": "1","37.369698,-121.923599": "1","37.369675,-121.923538": "1","37.369675,-121.923515": "1","37.369686,-121.923508": "1","37.369812,-121.923737": "1","37.369877,-121.923698": "1","37.34236,-122.072685": "1","34.044117,-84.316635": "1","37.36799,-121.91972": "1","37.794117,-122.400505": "1","19.16723,72.85326": "1","1.352083,103.819836": "1","28.583786,77.337351": "1","37.435482,-122.09642": "1","41.03465,-73.710976": "1","37.369335,-121.920746": "1","37.3743725,-121.9180298": "1","37.368156,-121.91985": "1","19.00033,72.82738": "1","19.0799904,72.85115719": "1","37.367886,-121.91965": "1","19.099621,72.867728": "1","34.36368,-84.0839": "1","37.2017,-121.84448": "1","28.591758,77.278652": "1","28.540644,77.173574": "1","37.368427,-121.92006": "1","19.04167,73.02045": "1","31.4769664,74.3323054": "1","37.201458,-121.84444": "1","42.971138,-85.6717": "1","37.3689891,-121.92318800000001": "1","37.3689019,-121.92310760000001": "1","33.902199,-84.457741": "1","38.936016,-77.36663": "1","38.90402,-77.02067": "1","37.3689032,-121.92310769999997": "1","37.36947,-121.92075": "1","37.368355,-121.91984": "1","37.369442,-121.92111": "1","37.369026,-121.9204": "1","40.756706,-73.970535": "1","37.201744,-121.8441": "1","-6.4525752,106.905249": "1","37.369938,-121.92108": "1","-14.235004,-51.92528": "1","51.5106225,-0.1364064217": "1","-33.0400085,151.5615034": "1","37.3689043,-121.92310889999997": "1","37.39316,-121.97952": "1","37.36935,-121.92062": "1","32.775646,-96.80407": "1","37.368385,-121.91986": "1","37.2503579,-121.8670893": "1","49.28773,-123.11963": "1","37.3689053,-121.92310880000001": "1","37.37009,-121.9212": "1","32.7945,-96.80459": "1","37.370228,-121.92131": "1","40.014587,-75.24236": "1","42.42287,-71.12041": "1","37.368538,-121.91998": "1","37.368912699999996,-121.9231103": "1","38.937923,-77.373245": "1","38.93654,-77.373886": "1","38.902668,-77.07195": "1","38.936165,-77.36652": "1","38.94476,-77.360176": "1","36.039185,-115.16186": "1","37.3689135,-121.92311110000001": "1","36.10287,-115.17462": "1","36.102066,-115.1746": "1","38.93671,-77.374275": "1","38.93656,-77.37393": "1","38.930874,-77.36131": "1","42.255394,-87.97301": "1","43.065582,-83.693726": "1","37.36957,-121.9208": "1","37.370483,-121.91924": "1","37.37,-121.92139": "1","36.120777,-115.17634": "1","36.122097,-115.17634": "1","36.121742,-115.17634": "1","38.9368,-77.37445": "1","38.936283,-77.36644": "1","38.936775,-77.37443": "1","28.45068,77.08755": "1","37.368645,-121.92007": "1","37.368919399999996,-121.92311210000001": "1","37.36846,-121.91992": "1","37.3687398,-121.9230723": "1","37.369507,-121.920784": "1","37.368423,-121.91989": "1","38.93655,-77.37391": "1","38.93667,-77.37417": "1","38.93682,-77.37449": "1","38.936478,-77.37374": "1","38.936455,-77.373695": "1","38.936604,-77.374016": "1","37.36942,-121.917305": "1","39.752213,-75.54756": "1","31.476809399999997,74.332703": "1","37.3689251,-121.92311579999998": "1","37.3389791,-121.8959151": "1","-33.963107,18.4816693": "1","38.94245,-95.78822": "1","-33.963109700000004,18.4816766": "1","17.98181,74.28968": "1","37.36916,-121.92047": "1","-33.8674869,151.2069902": "1","-33.963706699999996,18.478283299999998": "1","-33.9640814,18.4783594": "1","37.424194,-122.078865": "1","37.422787,-122.08794": "1","37.3689241,-121.92311559999999": "1","37.42412,-122.0941": "1","40.7629707,-73.9857415": "1","42.95565,-72.55775": "1","39.951397,-75.17866": "1","18.52032,73.87675": "1","40.6768606,-88.40141059": "1","41.9010945,-87.85804043": "1","28.50166,77.0766": "1","40.6885015,-74.15373304": "1","40.5410129,-74.39410203": "1","40.7143528,-74.00597309999999": "1","37.3689262,-121.92311590000001": "1","37.37833,-122.034164": "1","37.377953,-122.03429": "1","54.7126333,-2.81950292": "1","51.3461679,-0.2464216": "1","37.3689293,-121.92311819999998": "1","51.3854015,-0.2739082": "1","37.3689294,-121.92311819999998": "1","37.36943,-121.92072": "1","19.14667,72.946": "1","19.22807,73.10713": "1","37.638172,-122.41096": "1","51.3631991,-0.3845411157": "1","37.3689312,-121.9231196": "1","37.365096199999996,-121.92113250000001": "1","37.387367,-122.050995": "1","37.201576,-121.844055": "1","37.3689345,-121.92312139999999": "1","37.368933600000005,-121.92312039999999": "1","30.265833,-97.74528": "1","37.419725,-122.069277": "1","37.425756,-122.072124": "1","37.3689339,-121.92312050000001": "1","38.936787,-77.36605": "1","37.370052,-121.92117": "1","35.0994,-80.72306": "1","37.3689374,-121.92312299999998": "1","38.936756,-77.37436": "1","38.884907,-77.10212": "1","34.095966,-84.24162": "1","37.3703401,-121.9231352": "1","37.3689371,-121.92312129999999": "1","33.950596,-84.22915": "1","33.957413,-84.21141": "1","51.3296864,-0.3588535": "1","47.162494,19.503304": "1","18.55901,73.81146": "1","37.1923072,-121.859041": "1","37.369198,-121.9205": "1","47.60264,-122.32848": "1","28.3947,-81.24533": "1","42.11799,-87.9255": "1","37.20128,-121.84398": "1","39.8787,-105.00591": "1","38.88317,-77.31445": "1","38.883713,-77.31469": "1","37.369545,-121.920815": "1","37.554123,-122.29551": "1","25.741667,-80.27862": "1","38.936745,-77.37434": "1","38.884293,-77.31091": "1","18.5616666,73.8122419": "1","36.1094934,-115.1745612": "1","37.332073,-121.894585": "1","37.797302,-121.96177": "1","42.37943,-83.44001": "1","42.40288,-83.4318": "1","36.0959582,-115.1729561": "1","37.316772,-122.04962": "1","38.93681,-77.374466": "1","51.3256681,-0.3534151137": "1","54.4913024,-2.681479804": "1","14.5719134,120.9940347": "1","11.5917095,122.0153627": "1","38.93948,-77.36408": "1","38.886223,-77.09526": "1","19.0608875,72.86280841": "1","38.88675,-77.09526": "1","38.93505,-77.37056": "1","45.4652412,9.166069653": "1","51.605208,-0.1366251175": "1","11.7238316,121.9720668": "1","40.70886,-74.00748": "1","40.708817,-74.0075": "1","40.70638,-74.01606": "1","51.3258994,-0.3522594447": "1","41.033886,-73.712715": "1","41.033756,-73.71301": "1","41.022514,-73.7097": "1","41.033512,-73.75544": "1","41.0333,-73.76173": "1","41.02902,-73.7574": "1","41.024616,-73.74189": "1","41.030582,-73.75552": "1","41.03334,-73.76183": "1","41.03069,-73.75578": "1","41.018703,-73.728226": "1","18.5574454,73.809721": "1","39.35373,-76.38514": "1","39.346413,-76.40106": "1","39.332336,-76.43194": "1","42.522312,-71.03868": "1","28.420057,-81.48949": "1","37.86361,-122.25889": "1","38.917465,-77.24688": "1","40.750175,-74.00145": "1","37.2059597,-121.84682300000001": "1","37.205961099999996,-121.84682450000001": "1","42.26258,-87.96304": "1","26.0812621636364,116.673558672727": "1","42.158165,-87.8887": "1","45.434116,-122.755684": "1","19.1199838073323,72.9231464317029": "1","39.088234,-77.520164": "1","18.5299318,73.8756348": "1","37.33943,-122.06937": "1","37.316574,-122.0494": "1","51.328726499999995,-0.3577013": "1","37.7254862333333,-1.1241889": "1","51.33837090000001,-0.3196903": "1","52.4842357,13.343067099999999": "1","37.341595,-122.077385": "1","37.3684614,-121.9227693": "1","38.031696,-78.51801": "1","38.031345,-78.51801": "1","38.03157,-78.51801": "1","37.3689375,-121.9231069": "1","37.2059668,-121.84684639999999": "1","37.2033872,-121.8509177": "1","37.370197,-121.92129": "1","37.2025,-121.844444": "1","37.202225,-121.844444": "1","38.931423,-77.370026": "1","38.93154,-77.36994": "1","37.368576,-121.92001": "1","49.287518,-123.11868": "1","36.35,-96.09861": "1","38.9314,-77.37005": "1","37.204346,-121.844795": "1","27.9230601,-82.59110471": "1","37.37012,-121.92123": "1","37.371635,-122.08289": "1","37.7871,-122.39188": "1","37.79081,-122.39413": "1","37.2019776,-121.8461093": "1","38.931885,-77.369705": "1","37.3929259,-122.1651078": "1","37.445305,-122.1564": "1","37.37492,-121.93705": "1","37.353283,-122.056206": "1","37.3684619,-121.9229822": "1","37.58347,-122.27806": "1","37.578503,-122.27784": "1","37.583733,-122.27807": "1","37.367462,-121.919136": "1","37.368057,-121.9196": "1","37.793533,-122.39758": "1","52.3898996,-0.970645743": "1","52.2710227,-0.9570366163": "1","37.389454,-121.95802": "1","40.71169,-74.01097": "1","20.0078524,110.2809982": "1","40.720947,-74.01428": "1","51.46631,-0.230489406": "1","40.706326,-74.01608": "1","51.4785402,-0.2321756821": "1","37.37036,-121.921455": "1","37.3685,-121.91995": "1","37.77095,-121.96032": "1","37.75735,-121.89267": "1","38.939243,-77.379875": "1","38.93934,-77.38009": "1","39.959656,-75.15403": "1","37.381462,-121.92019": "1","38.93125,-77.370155": "1","38.938847,-77.379": "1","41.34814,-74.1839": "1","41.34414,-74.164276": "1","40.69183,-73.94939": "1","38.796254,1.345731875": "1","37.370495,-121.921524": "1","37.579723,-122.27789": "1","38.9312,-77.3702": "1","51.4608593,-0.2416679483": "1","18.562536599999998,73.80561560000001": "1","37.37043,-121.92151": "1","37.45104,-122.17836": "1","18.5625006,73.8056175": "1","37.425537,-122.145775": "1","51.5984472,-1.105728921": "1","37.370247,-121.921364": "1","50.9180903,-3.298632953": "1","38.754932,-90.75127": "1","38.759686,-90.74918": "1","38.752186,-90.752464": "1","37.670944,-122.0673": "1","37.563667,-122.27192": "1","37.56218,-122.27517": "1","38.934597,-77.36769": "1","40.75308,-73.97817": "1","18.561969899999998,73.8054896": "1","21.877958,-159.48929": "1","40.00796,-75.24665": "1","50.875606,-3.289051523": "1","42.202152,-87.88924": "1","19.1053458,72.81030441": "1","19.1614228,75.7194698": "1","51.4971079,-0.1966861149": "1","50.1299296,8.67622405": "1","39.745495,-75.55804": "1","39.74633,-75.54947": "1","51.5095606,-0.1351164903": "1","51.4814491,-0.001426636606": "1","51.5128183,-0.1383926576": "1","53.7840867,-2.838480819": "1","51.4089137,-1.40302372": "1","37.523422,-122.26598": "1","37.51707,-122.31527": "1","37.3743461,-122.3441789": "1","18.5620716,73.8059655": "1","18.5248119,73.8759159": "1","51.2050562,10.38367402": "1","37.166134,-121.8374": "1","52.2561213,-1.960908342": "1","42.20216,-87.88924": "1","52.9908031,-1.366499676": "1","38.939396,-77.38022": "1","29.951004,-90.06301": "1","29.950699,-90.06301": "1","52.7461497,-2.099882524": "1","37.209774,-121.8482577": "1","37.3730825,-121.9293983": "1","37.332085,-121.89465": "1","50.9171174,-3.302510171": "1","37.2033539,-121.8511432": "1","55.9722324,-3.336511824": "1","55.8397986,-4.27107739": "1","27.8852531,-82.61287137": "1","29.9166846,-114.5310917": "1","52.840778,-2.115955859": "1","38.89802,-77.07688": "1","52.7880763,-2.086665796": "1","37.369236,-121.92053": "1","29.5879969,-95.6631069": "1","27.9219011,-82.59415921": "1","29.3551262,-95.73302828": "1","37.369793,-121.92097": "1","29.7395728,-95.56968507": "1","37.370323,-121.921425": "1","37.370506,-121.92157": "1","37.37021,-121.92133": "1","50.0026277,8.299816018": "1","47.4903688,7.591854991": "1","18.9583233,72.81246639999999": "1","28.5501919,77.16011295": "1","18.5613055,73.80458584": "1","37.203685,-121.8470388": "1","37.36418,-121.92396": "1","18.563913,73.80646408": "1","18.5733783,73.87670603": "1","37.238293,-121.89192": "1","18.5291852,73.88182854": "1","37.1914919,-121.8600916": "1","18.5638929,73.80617738": "1","18.5648965,73.80932518": "1","37.4051,-122.147484": "1","27.2603686,-82.33326451": "1","19.0534866,72.86357459": "1","19.0539917,72.863298": "1","29.9612789,-95.4671377": "1","29.9767779,-95.43498588": "1","37.3742469,-121.9199861": "1","51.4717882,-0.2358836052": "1","18.6233113,73.82959509": "1","37.2001179,-121.8377322": "1","14.6577046,-17.39784838": "1","18.5668687,73.80705834": "1","37.2059413,-121.8473756": "1","37.201664,-121.844086": "1","50.8726847,-3.287866074": "1","18.5252139,73.87670475": "1","18.9511017,72.81657542": "1","28.478056,-81.50611": "1","7.76548512,80.1661539": "1","6.88860942,79.8585522": "1","37.368683,-121.9201": "1","37.38952,-122.074135": "1","37.390427,-122.075165": "1","37.36876,-121.92016": "1","7.84697579,80.20515646": "1","13.0079671,77.55948676": "1","6.91782695,79.86301619": "1","19.0080561,72.83544961": "1","19.1038034,72.89614366": "1","19.1152771,72.8951763": "1","19.0162238,72.82775443": "1","37.368614,-121.920044": "1","19.0162055,72.83052145": "1"}');
var taxiData = [];
var locWgt = {loc:[]};
var value = "1";
var latlng3 = "";
var jsonData = {};
var sptLatLng;
$.each(latlng, function(idx, value) {
sptLatLng = idx.split(",");
jsonData['location']=new google.maps.LatLng(sptLatLng[0],sptLatLng[1]);
jsonData['weight']=value;
locWgt.loc.push(jsonData);
});
taxiData = [locWgt['loc']];
function initialize() {
var mapOptions = {
zoom: 6,
center: new google.maps.LatLng(sptLatLng[0],sptLatLng[1]),
mapTypeId: google.maps.MapTypeId.HYBRID
};
map = new google.maps.Map(document.getElementById('map-canvas'),
mapOptions);
var pointArray = new google.maps.MVCArray(taxiData[0]);
heatmap = new google.maps.visualization.HeatmapLayer({
data: pointArray,
radius: 30
});
heatmap.setMap(map);
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
</head>
<body>
<div id="panel">
<button onclick="toggleHeatmap()">Toggle Heatmap</button>
<button onclick="changeGradient()">Change gradient</button>
<button onclick="changeRadius()">Change radius</button>
<button onclick="changeOpacity()">Change opacity</button>
</div>
<!--<div id="map-canvas"></div>//-->
<div id="map-canvas" style="position:absolute; left:100px; top:60px; width:80%; height:80%"></div>
</body>
</html>
但是当我使用{location: new google.maps.LatLng(19.0162055,72.83052145), weight: 1}
创建热图数据时,输出是正确的
我的代码出了什么问题。我收到这组数据的错误只是为了休息所有代码都正常工作。
Update 1
在创建latlong时添加parseFloat并在添加重量时添加parseFloat我现在在印度上以圆形模式获取热图。见下图。
但热图中缺少所有数据的其余部分。为什么会这样?
答案 0 :(得分:1)
这对我有用。改变你的循环:
$.each(latlng, function(idx, value) {
sptLatLng = idx.split(",");
locWgt.loc.push({
location: new google.maps.LatLng(parseFloat(sptLatLng[0]), parseFloat(sptLatLng[1])),
weight: parseFloat(value)
});
});
在所有数据周围使用parseFloat,也使用匿名变量而不是您不断更新的变量:
GetComponent.<Rigidbody>()