2015-11-08 86 views
0

我想從數據庫中選擇我的地理數據。我聲明瞭數據類型十進制(12,8)。我想選擇從數據庫,這是因爲有幾個點擊會顯示幾個maps.lat和lng值就會產生變化動態InvalidValueError:setCenter:不是LatLng或LatLngLiteral:屬性lat:不是數字

值,但它顯示

InvalidValueError: setCenter: not a LatLng or LatLngLiteral: in property lat: not a number. [

<?php 
 
if ($result!=NULL) { 
 
\t foreach ($result as $value) { 
 
\t \t $latitude=$value->latitude; 
 
\t \t $longitude=$value->longitude; 
 
\t ?> 
 
<script type="text/javascript"> 
 
    function intimap(){ 
 
var mapOptions={ 
 
center: {lat:<?php echo json_encode($latitude);?>,lng:<?php echo json_encode($longitude);?>}, 
 
zoom: 12, 
 
mapTypeId: google.maps.MapTypeId.ROADMAP 
 
}; 
 
var map=new google.maps.Map(document.getElementById(<?php echo json_encode($value->map_name);?>),mapOptions); 
 
var marker=new google.maps.Marker({ 
 
    position:{lat:<?php echo json_encode($latitude);?>,lng:<?php echo json_encode($longitude);?>}, 
 
    map: map, 
 
    title:<?php echo json_encode($value->place_title);?>, 
 
    animation:google.maps.Animation.BOUNCE 
 
}); 
 
} 
 
</script>

+1

歡迎來到SO!請發佈您的相關代碼。沒有那個,我們在黑暗中拍攝。 –

+1

顯示你的代碼.... – scaisEdge

+0

@ BrianKeller-Heikkila我添加了你所要求的代碼。 – hmamun

回答

0

我認爲你的問題是,當你設置標記變量時,你正在使用json_encode輸出你的值。只是在沒有json_encode的情況下回顯那些值,並且應該修復它。

+0

非常感謝。現在它工作:) – hmamun

相關問題