0

我正在尝试使用非常有用的元数据 jquery 插件jMapping使我的地图居中,但它根本不会居中。

尝试过快地初始化地图或以错误的顺序初始化地图是否存在问题 - 我在这里错过了什么......?

// Map init
$(function() {

// styles
var styles = [{

    //  background colour
    featureType: "water",
    elementType: "all",
        stylers: [ { 
            color: '#E7E4DD' }, { visibility: "on" }
        ]
    }, 

    { //  Turn off roads
    featureType: "road",
        stylers: [ 
            { "visibility": "off" }
        ]
    },

    { //  Turn off transit
    featureType: "transit",
        stylers: [ 
            { "visibility": "off" }
        ]
    },

    { //  Turn off administrative
    featureType: "administrative",
        stylers: [ 
            { "visibility": "off" }
        ]
    },  
    { //  country line
    featureType: "administrative.country",
    elementType: "geometry.stroke",
        stylers: [ 
            { "visibility": "on" },
            { "color": "#0068f4"},
            { "weight": "0.7"}
        ]
    },
    { //  style landscape
    featureType: "landscape",
    elementType: "all",
        stylers: [ 
            { "color": "#002E6C" }
        ]
    },

    { //  points of interest
    featureType: "poi",
        stylers: [
            { "color": "#002E6C" }
        ]
    },

    { //  labels
    elementType: "labels",
        stylers: [
            { "visibility": "off" }
        ]
}];

// map options
var mapOptions = {
    zoom: 3,
    center: new google.maps.LatLng(51.165691, 10.451526),
    mapTypeId: google.maps.MapTypeId.ROADMAP,
    disableDefaultUI: false,
    styles: styles,
    minZoom: 3,
    maxZoom: 10
};

// call the map jMapping
$('#map').jMapping({
    map_config: mapOptions,
    default_zoom_level: 2,
    metadata_options: {type: 'html5'},
    category_icon_options: function(category){

        if (category.match('experience')) { // if the category is experience, use custom marker

          return new google.maps.MarkerImage('/wp-content/themes/ichron/assets/map/images/marker.png');

       } 

     }
});

});

4

1 回答 1

0

我有这样的事情,如果我没记错的话,您所经历的是在 api 响应之前绘制地图的结果。

这是很久以前的事了,但我相信这是已经到位的延迟:

setTimeout(function() {
       initialize();
}, 500);
于 2013-07-28T02:06:00.353 回答