我想将值附加为列表。但不知怎的,我无法做到这一点。
当我尝试添加它时,它只是与其他列表重叠。当我添加CSS以摆脱重叠时,我无法进行点击事件。您可以在下面的图片中看到。
以下是我用来将值附加到列表中的代码:
$.getJSON('path to json', function(data) {
$.each( data.markers, function(i, value) {
var radlat1 = Math.PI * position.coords.latitude/180;
var radlat2 = Math.PI * value.latitude/180;
var radlon1 = Math.PI * position.coords.longitude/180;
var radlon2 = Math.PI * value.longitude/180;
var theta = position.coords.longitude-value.longitude;
var radtheta = Math.PI * theta/180;
var dist = Math.sin(radlat1) * Math.sin(radlat2) + Math.cos(radlat1) * Math.cos(radlat2) * Math.cos(radtheta);
dist = Math.acos(dist);
dist = dist * 180/Math.PI;
dist = dist * 60 * 1.1515;
dist = dist * 1.609344;
if(dist<10){
var myLatlng = new google.maps.LatLng(value.latitude, value.longitude);
var marker = new google.maps.Marker({
position: myLatlng,
map: map,
title: "text "+value.longitude
});
$(".newclasscheck").append("<li>"+value.content+"</li>");
}
});
});
我的PHP代码如下所示:
<ul class="newclasscheck"></ul>
<ul class="check">
<?php
foreach($result as $results)
{
$atag = "#filter-list-".$results->fax;
$results->wpsl_id;
$results->store.'<br/>';
$results->address.'<br/>';
$results->address2.'<br/>';
$results->city.'<br/>';
$results->state.'<br/>';
$results->country.'<br/>';
$results->description.'<br/>';
$results->phone.'<br/>';
$posts[] = array('latitude'=> $results->lat, 'longitude'=> $results->lng, 'area'=>$atag, 'content'=> $results->store);
?>
<li class="area-element <?php echo $results->fax; ?>"><div><p><strong class="lstore <?php echo $results->store; ?>" data-value-lat="<?php echo $results->lat; ?>" data-value-lng="<?php echo $results->lng; ?>"><?php echo $results->store; ?></strong><span class='wpsl-street'><?php echo $results->address;?></span><span class='wpsl-street'><?php echo $results->address2;?></span><?php echo $results->city ."". $results->state ."".$results->zip ; ?></p><span><a href="?page_id=417&store_id=<?php echo $results->wpsl_id ?>" class='more-details'>More details</a></span></div></li>
<?php
}
?>
我应该怎么做才能打印出与check
班级相同的列表?我缺少哪里?