3

私はjsを書くのが苦手です。グーグルマップを作成してカスタマイズする必要があります。このために私はjquery-ui-mapプラグインとこ​​のコードを使用します:

if ($("#map_canvas").length){
$('#map_canvas').gmap().bind('init', function(ev, map) {
    $("[data-gmapping]").each(function(i,el) {
        var data = $(el).data('gmapping');
        $('#map_canvas').gmap('addMarker', {'id': data.id, 'tags':data.tags, 'position': new google.maps.LatLng(data.latlng.lat, data.latlng.lng), 'bounds':true }, function(map,marker) {

            $(el).click(function() {
                $(marker).triggerEvent('click');
            });
            }).click(function() {
                $('#map_canvas').gmap('openInfoWindow', { 'content': $(el).find('.info-box').html() }, this);
            });
    }); 
});
}

この生成された変数をどこに入れる必要がありますか?

{ stylers: [ { lightness: 7 }, { saturation: -100 } ] }

私が使用したリンク: http ://code.google.com/p/jquery-ui-map/ http://gmaps-samples-v3.googlecode.com/svn/trunk/styledmaps/wizard/index.html

4

1 に答える 1

4

マップのインスタンス化など、配置する場所はたくさんあります。

今:

$('#map_canvas').gmap()  //...more code

それから:

$('#map_canvas').gmap({styles:[{stylers:[{lightness:7},{saturation:-100}]}]})  //...more code

gmap-constructor は、受け入れるすべてのオプションをgoogle.maps.Map.setOptions()受け入れます。これらのオプションの 1 つは「スタイル」ですgoogle.maps.MapTypeStyle

于 2012-03-25T22:40:21.513 に答える