[英]Retrieve google map coordinates from mySQL with 5 location in a row?
Assuming I have 5 locations in a row of data call locationOne, locationTwo, locationThree, locationFour, locationFive. 假设我在数据调用行中有5个位置locationOne,locationTwo,locationThree,locationFour,locationFive。 How do i call all of them and show in google map in below ?
我该怎么称呼它们并在下面的Google地图中显示? Below show retrieve out one.
下面显示检索出一个。
var marker = new google.maps.Marker({
position: new google.maps.LatLng<?php echo $location['locationOne']; ?>,
map: map,
});
Thanks. 谢谢。
0 Create an array of all locations: 0创建所有位置的数组:
var locs = [
['Location name 1', -33.890542, 151.274856, 4],
['Location name 2', -33.923036, 151.259052, 5]
];
Display 显示
for (i = 0; i < locs.length; i++) { 对于(i = 0; i <locs.length; i ++){
marker = new google.maps.Marker({ position: new google.maps.LatLng(locs[i][1], locs[i][2]), map: map }); marker = new google.maps.Marker({position:new google.maps.LatLng(locs [i] [1],locs [i] [2]),map:map});
if $location is an array like $location['locationOne'], $location['locationTwo'], etc, use something like this: 如果$ location是一个数组,例如$ location ['locationOne'],$ location ['locationTwo']等,请使用以下内容:
<?php foreach($location as $location){ ?>
var marker = new google.maps.Marker({
position: new google.maps.LatLng(<?php echo $location; ?>),
map: map,
});
<?php } ?>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.