Question

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

Was it helpful?

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)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top