【问题标题】:Google map with auto zoom and custom markers stays grey具有自动缩放和自定义标记的谷歌地图保持灰色
【发布时间】:2014-02-06 15:20:01
【问题描述】:

大家好,我很难让我的 Google 地图使用自动缩放和自定义标记。在 Google chrome 控制台中,我得到了

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 文件由 Google 托管在这里 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 fiddle http://jsfiddle.net/KwayW/48/

任何帮助都将不胜感激

【问题讨论】:

    标签: google-maps google-maps-markers


    【解决方案1】:

    你有两个问题:

    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

    顺便说一句 - 你所有的标记都在同一个位置...

    【讨论】:

    猜你喜欢
    • 2014-12-21
    • 2017-10-14
    • 1970-01-01
    • 1970-01-01
    • 2013-08-21
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多