2013-01-11 39 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