2013-01-11 38 views
1

嘿,我很難讓我的Google地圖使用自動縮放和自定義標記。谷歌瀏覽器的控制檯,我得到帶自動縮放和自定義標記的Google地圖保持灰色

too much recursion 
...(0,0);Ba(T[I],function(){return"("+this.x+", "+this.y+")"});T[I].b=function(a){r... 
main.js (ligne 24) 

too much recursion 
...nged")}var Lf={};function If(a){return Lf[a]||(Lf[a]=a[Bb](0,1).toUpperCase()+a[... 
main.js (ligne 25) 

的main.js文件是由谷歌託管這裏http://maps.gstatic.com/intl/fr_ALL/mapfiles/api-3/10/19/main.js

我真的不明白

<?php 
print (' 
<script type="text/javascript"> 
    $(function(){ 
     var map; 
     var markersArray = []; 
     var image = \'img/\'; 
     var bounds = new google.maps.LatLngBounds(); 
     var loc; 

     var mapOptions = { mapTypeId: google.maps.MapTypeId.ROADMAP }; 

     map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions); 

     '); 

      $l=1; 
      foreach($carte as $value){ 
       if ($carte[$l][lat]&&$carte[$l][lon]){ 
       /*echo ' 
        loc = new google.maps.LatLng("'.$carte[$l][lat].'","'.$carte[$l][lon].'"); 
        bounds.extend(loc); 
        addMarker(loc, \'Event A\', "active"); 
       ';*/ 

       echo ' 
        loc = new google.maps.LatLng("'.$carte[$l][lat].'","'.$carte[$l][lon].'"); 
        bounds.extend(loc); 
        addMarker(loc, \''.htmlentities($carte[$l][nom], ENT_QUOTES).str_replace('<br />', '', htmlentities($carte[$l][addresse], ENT_QUOTES)).'\', "active", "'.$l.'"); 

       '; 

       } 


       $l++; 
      } 


     print (' 

     map.fitBounds(bounds); 
     map.panToBounds(bounds);  

     function addMarker(location, name, active) {   
      var marker = new google.maps.Marker({ 
       position: location, 
       map: map, 
       title: name, 
       status: active 
      }); 
     } 

    }); 

</script>'); 
?> 

我在這裏做一個js小提琴 http://jsfiddle.net/KwayW/48/問題

現在任何幫助都可以折扣

回答

4

你有兩個問題:

  1. 您傳遞字符串到google.maps.LatLng constructor

  2. 該字符串表示中有一個逗號而不是小數點

google.maps.LatLng要求兩個數字。

loc = new google.maps.LatLng("47,036084","-70,461227"); 

應該是:

loc = new google.maps.LatLng(47.036084,-70.461227); 

Updated JSFiddle

順便說一句 - 你所有的標誌都在同一個位置......

+0

[更新的jsfiddle](http://jsfiddle.net/rGBzv/2 /),因爲StackOverflow不會讓我發佈包含它的答案。 – geocodezip

+0

Thx解決了我的問題! – user1970938