Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/68.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
jquery ui映射如何设置缩放级别_Jquery_Google Maps_Jquery Ui Map - Fatal编程技术网

jquery ui映射如何设置缩放级别

jquery ui映射如何设置缩放级别,jquery,google-maps,jquery-ui-map,Jquery,Google Maps,Jquery Ui Map,我有以下代码工作正常,但我无法添加缩放级别。根据规定,它应该与“选项”、“缩放”7一起工作,但这会给出一个错误:“$”(“#map_canvas”).gmap(“选项”、“缩放”,7)。绑定不是一个函数” 工作代码,无缩放,已编辑。缩放始终为1 $("#map_trigger").click(function(){ var prop_id = $("#map_canvas").attr("rel"); $('#map_canvas').gmap({'zoom':6

我有以下代码工作正常,但我无法添加缩放级别。根据规定,它应该与
“选项”、“缩放”7一起工作,但这会给出一个错误:
“$”(“#map_canvas”).gmap(“选项”、“缩放”,7)。绑定不是一个函数”

工作代码,无缩放,已编辑。缩放始终为1

$("#map_trigger").click(function(){
        var prop_id = $("#map_canvas").attr("rel");
        $('#map_canvas').gmap({'zoom':6}).bind('init', function(evt, map) {
            $.getJSON( basepath+'properties/get_gps_coords/'+prop_id, function(data) {
                $.each( data.markers, function(i, m) {
                    lat = m.latitude;
                    longitude = m.longitude;
                    $('#map_canvas').gmap(
                        'addMarker', { 'position': new google.maps.LatLng(lat, m.longitude), 'bounds':true }
                    );
                });
            });
        });
    });
如何将缩放级别添加到此片段?

使用:

$("#map_canvas").gmap({'zoom':7})

当映射已经初始化并且不会返回jQuery对象时,可以使用option方法,因此它是不可链接的(这将解释您得到的错误)。

此代码适用于我:

<!doctype html>
<html>
    <head>
        <meta http-equiv="content-language" content="es">
        <meta charset="utf-8">

        <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script> 
        <script type="text/javascript" src="js/jquery-1.7.1/jquery.min.js"></script>
        <script type="text/javascript" src="../ui/jquery.ui.map.js"></script>

    </head>
    <body>
        <div style="height: 500px; width:500px;" id="map_canvas"></div>
        <button id="btnChangeZoom">change zoom</button>
        <script type="text/javascript">
        $(function() {
            $('#map_canvas').gmap({ 'center': '40.33238,-3.76546','scrollwheel':false});
            $('#map_canvas').gmap('option', 'mapTypeId', google.maps.MapTypeId.SATELLITE);
            $('#map_canvas').gmap('option', 'zoom', 17);
            });

        $("#btnChangeZoom").click(function(){changeZoom()});

        function changeZoom(){
            $('#map_canvas').gmap('option', 'zoom', 10);
        }   
        </script>
    </body>
</html>

更改缩放
$(函数(){
$('map_canvas').gmap({'center':'40.33238,-3.76546','scrollwheel':false});
$('map_canvas').gmap('option','mapTypeId',google.maps.mapTypeId.SATELLITE);
$('map#u canvas').gmap('option','zoom',17);
});
$(“#btnChangeZoom”)。单击(函数(){changeZoom()});
函数changeZoom(){
$('map#u canvas').gmap('option','zoom',10);
}   

您需要将地图居中,然后缩放地图。下面是一个代码示例

$('#map_canvas').gmap({'center': '43.1502, 25.02083'})
$('#map_canvas').gmap('option', 'zoom', 10);
$('#map_canvas').gmap('addMarker', {'position': '43.1502, 25.02083', 'icon': '/picnic/img/Pin.png'}).click(function() {
    //$('#map_canvas').gmap('openInfoWindow', {'content': 'Hello World!'}, this);
});

它不是最大值,它是显示所有标记所必需的缩放,因为在标记创建过程中将“边界”设置为true。将边界设置为false,并将贴图中心设置为标记位置