Search code examples
google-mapsgoogle-maps-api-3jquery-ui-map

How to use Google Maps Stylers with jquery-ui-map plugin?


i'm too weak on writing js. I need to build and customize a google map. For this i do use the jquery-ui-map plugin and this code:

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);
            });
    }); 
});
}

Where do i have to put in this generated variables:

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

Links i used: http://code.google.com/p/jquery-ui-map/ http://gmaps-samples-v3.googlecode.com/svn/trunk/styledmaps/wizard/index.html


Solution

  • There are many places to put it, e.g. into the instantiating of the map:

    now:

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

    then:

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

    the gmap-constructor accepts all options that google.maps.Map.setOptions() accepts. One of those options is "style", which is expected to be an array with google.maps.MapTypeStyle's (your generated output is a MapTypeStyle)