Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/431.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
Javascript jquery ui映射集缩放级别_Javascript_Jquery_Jquery Ui_Google Maps - Fatal编程技术网

Javascript jquery ui映射集缩放级别

Javascript jquery ui映射集缩放级别,javascript,jquery,jquery-ui,google-maps,Javascript,Jquery,Jquery Ui,Google Maps,我有下面的代码来说明如何绘制地图。除了“缩放”参数外,所有操作都正常。无论我为缩放设置了什么,它始终显示相同的缩放级别。我能做什么 $('#pagemap').live("pageshow", function() { $('#map_canvas').gmap().bind('init', function(evt, map) { $('#map_canvas').gmap('getCurrentPosition', function

我有下面的代码来说明如何绘制地图。除了“缩放”参数外,所有操作都正常。无论我为缩放设置了什么,它始终显示相同的缩放级别。我能做什么

$('#pagemap').live("pageshow", function() {

            $('#map_canvas').gmap().bind('init', function(evt, map) {

                $('#map_canvas').gmap('getCurrentPosition', function(position, status) {

                        if ( status === 'OK' ) {

                            var clientPosition = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);

                            $('#map_canvas').gmap('option', 'mapTypeId', google.maps.MapTypeId.SATELLITE);

                            $('#map_canvas').gmap('option', 'zoom', 13);            

                            $('#map_canvas').gmap('addMarker', {'position': clientPosition, 'bounds': true});

                        }
                });   
            });
      });

您需要将标记的“边界”选项更改为false

$('map_canvas').gmap('addMarker',{'position':clientPosition,'bounds':false})

如果将属性边界设置为true,则贴图将自动计算视口和缩放,并覆盖构造函数中的任何缩放集 大宗报价


是获取更多信息的链接

我正面临解决方案的问题。如果将边界设置为false,则贴图将保持在其初始中心坐标的中心。好的。那为什么我的地图是以一根大头针为中心的呢?好的,没问题。但如果在添加标记后仍要设置特定的缩放级别

$("your-selector").gmap('addMarker', { 
    'position': latlng, 
    'bounds': true
}, function(map, marker) {
    map.set('zoom', 12);
}).click(function() {
    $(this.container).gmap('openInfoWindow', { 'content': 'TEXT_AND_HTML_IN_INFOWINDOW' }, this);
});
您只需回调gmap函数。但是,大家,现在不是该纠正这个插件API文档中所有断开的链接的时候了吗?现在不是为任何插件编写明确的Javascript文档的时候了吗?让我们互相帮助吧,这条路很复杂。我们正在浪费很多时间

试试这个,看看缩放级别代码中的“缩放:9”


变量标记=[{
“标题”:“哈瓦那”,
“lat”:“23.1330200”,
“液化天然气”:“-82.3830400”,
“描述”:“何塞·马蒂国际机场,哈瓦那”
}
,
{
“标题”:“坦帕”,
“lat”:“27.964157”,
“液化天然气”:“-82.452606”,
“描述”:“坦帕国际机场,坦帕”
}
,
{
“标题”:“奥兰多”,
“lat”:“28.538336”,
“液化天然气”:“-81.379234”,
“描述”:“奥兰多国际机场,奥兰多”
}
,
{
“标题”:“哈瓦那”,
“lat”:“23.1330200”,
“液化天然气”:“-82.3830400”,
“描述”:“何塞·马蒂国际机场,哈瓦那”
}
,
{
“标题”:“哈瓦那”,
“lat”:“23.1330200”,
“液化天然气”:“-82.3830400”,
“描述”:“何塞·马蒂国际机场,哈瓦那”
}
,
{
“头衔”:“迈阿密”,
“lat”:“25.7742700”,
“液化天然气”:“-80.1936600”,
“描述”:“迈阿密国际机场,迈阿密”
}
,
{
“头衔”:“卡马圭·伊格纳西奥·阿格拉蒙特”,
“lat”:“21.416667”,
“液化天然气”:’-77.866667’,
“描述”:“卡马圭伊格纳西奥阿格拉蒙特机场,卡马圭”
}
,
{
“头衔”:“卡马圭·伊格纳西奥·阿格拉蒙特”,
“lat”:“21.416667”,
“液化天然气”:’-77.866667’,
“描述”:“卡马圭伊格纳西奥阿格拉蒙特机场,卡马圭”
}
,
{
“标题”:“坦帕”,
“lat”:“27.964157”,
“液化天然气”:“-82.452606”,
“描述”:“坦帕国际机场,坦帕”
}];
window.onload=函数(){
变量映射选项={
中心:新建google.maps.LatLng(标记[0].lat,标记[0].lng),
缩放:9,
mapTypeId:google.maps.mapTypeId.Streapmap
};
var map=new google.maps.map(document.getElementById(“dvMap”)、mapOptions);
var infoWindow=new google.maps.infoWindow();
var lat_lng=新阵列();
var latlngbounds=new google.maps.latlngbounds();
对于(i=0;i<div id="MyDivScrolling">
    <div>
        <script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?key=AIzaSyC8KY7rkZP7Xyq5oVM0nssUc4OPIP7MQtw&callback=initMap"></script>
        <script type="text/javascript">
            var markers = [{
            "title": 'Havana',
            "lat": '23.1330200',
            "lng": '-82.3830400',
            "description": 'José Martí International Airport, Havana'
        }
    ,
         {
             "title": 'Tampa',
             "lat": '27.964157',
             "lng": '-82.452606',
             "description": 'Tampa International Airport, Tampa'
         }
    ,
         {
             "title": 'Orlando',
             "lat": '28.538336',
             "lng": ' -81.379234',
             "description": 'Orlando International Airport, Orlando'
         }
    ,
        {
            "title": 'Havana',
            "lat": '23.1330200',
            "lng": '-82.3830400',
            "description": 'José Martí International Airport, Havana'
        }

    ,
        {
            "title": 'Havana',
            "lat": '23.1330200',
            "lng": '-82.3830400',
            "description": 'José Martí International Airport, Havana'
        }
      ,
        {
            "title": 'Miami',
            "lat": '25.7742700',
            "lng": '-80.1936600',
            "description": 'Miami International Airport, Miami'
        }
    ,
        {
            "title": 'Camagüey-Ignacio Agramonte',
            "lat": '21.416666666667',
            "lng": '-77.866666666667 ',
            "description": 'Camagüey-Ignacio Agramonte Airport, Camagüey'
        }


         ,
          {
              "title": 'Camagüey-Ignacio Agramonte',
              "lat": '21.416666666667',
              "lng": '-77.866666666667 ',
              "description": 'Camagüey-Ignacio Agramonte Airport, Camagüey'
          }
           ,
         {
             "title": 'Tampa',
             "lat": '27.964157',
             "lng": '-82.452606',
             "description": 'Tampa International Airport, Tampa'
         }];
            window.onload = function () {
                var mapOptions = {
                    center: new google.maps.LatLng(markers[0].lat, markers[0].lng),
                    zoom: 9,
                    mapTypeId: google.maps.MapTypeId.Streapmap
                };
                var map = new google.maps.Map(document.getElementById("dvMap"), mapOptions);
                var infoWindow = new google.maps.InfoWindow();
                var lat_lng = new Array();
                var latlngbounds = new google.maps.LatLngBounds();
                for (i = 0; i < markers.length; i++) {
                    var data = markers[i]
                    var myLatlng = new google.maps.LatLng(data.lat, data.lng);
                    lat_lng.push(myLatlng);
                    var marker = new google.maps.Marker({
                        position: myLatlng,
                        map: map,
                        title: data.title
                    });
                    latlngbounds.extend(marker.position);
                    (function (marker, data) {
                        google.maps.event.addListener(marker, "click", function (e) {
                            infoWindow.setContent(data.description);
                            infoWindow.open(map, marker);
                        });
                    })(marker, data);
                }
                map.setCenter(latlngbounds.getCenter());
                map.fitBounds(latlngbounds);

                //***********ROUTING****************//

                //Intialize the Path Array
                var path = new google.maps.MVCArray();

                //Intialize the Direction Service
                var service = new google.maps.DirectionsService();

                //Set the Path Stroke Color
                var poly = new google.maps.Polyline({ map: map, strokeColor: 'Blue' });

                //Loop and Draw Path Route between the Points on MAP
                for (var i = 0; i < lat_lng.length; i++) {
                    if ((i + 1) < lat_lng.length) {
                        var src = lat_lng[i];
                        var des = lat_lng[i + 1];
                        path.push(src);
                        poly.setPath(path);
                        service.route({
                            origin: src,
                            destination: des,
                            travelMode: google.maps.DirectionsTravelMode.DRIVING
                        }, function (result, status) {
                            if (status == google.maps.DirectionsStatus.OK) {
                                for (var i = 0, len = result.routes[0].overview_path.length; i < len; i++) {
                                    path.push(result.routes[0].overview_path[i]);
                                }
                            }
                        });
                    }
                }
            }
        </script>
        <div class="MainSliderItem2 ImagesContainerItem">
            <div id="dvMap" style="width: 100%;height: 490px;position: relative;overflow: hidden;background-color: rgb(229, 227, 223);max-width: 80%;margin: 98px auto;">
            </div>
        </div>
    </div>
</div>