Gmaps APIV3 accepts my x variable, but rejects my weight variable, although both are numbers. Whats going on here?
google.maps.event.addListener(map, 'zoom_changed', function() {
var zoomLevel = map.getZoom(); //something between 18-12
var weight = zoomLevel - 5;
var x = 3;
console.log(typeof(x)); // number
console.log(typeof(weight)); //number
$.each(paths, function(i, path){
path.setOptions({strokeWeight: x}); //works
// path.setOptions({strokeWeight: weight}); //doesn't work
})
});
Added javascript as a tag because I am unsure of whether this is strictly Gmaps related or a language thing I’m unaware of. Remove it if I’m wrong.
can it be that
zoomLevelsometimes has not the expected value(18-12) and is <6 ? If yes,weightwould be <=0 what is an illegal value.Assign at least 1:
With a zoomLevel >5 your script works for me.