这就是我想要完成的(接受的答案)。
var locations = [
['Bondi Beach', -33.890542, 151.274856, 4],
['Coogee Beach', -33.923036, 151.259052, 5],
['Cronulla Beach', -34.028249, 151.157507, 3],
['Manly Beach', -33.80010128657071, 151.28747820854187, 2],
['Maroubra Beach', -33.950198, 151.259302, 1]
];
不同之处在于值存储在数组中。我试过这个:
<?foreach($nearest_hospitals as $item):?>
var locations = [
[<?$item->H_NAME;?>, <?$item->H_LAT;?>, <?$item->H_LONG;?>, <?$item->H_ID;?>],
];
<?endforeach?>
有了这个,地图没有显示。请帮我。谢谢!