A clean way to set MapTypeControlOptions at run time

Looking at the documents, I did not find a way to set MapTypeControlOptions after the map object was created. There is nothing like the setMapTypeControlOptions method.

I came up with two ways to do this, both seem to work:

  • directly sets the property of the object: map.MapTypeControlOptions = { ... }

  • set all parameters again: map.setOptions({ mapTypeControlOptions: { ... } })

But I'm not quite sure if this is the right way to do this. In the first case, we directly change the property of the object, which is not very clean. In the second case, we set the entire options object. What will happen to unspecified options? Will they stay the same? Will they reset by default? I dont know. This information is completely missing from the API link. We can try something and it seems to work, but as long as this is not specified in the specification, this may be the wrong way, which works in all cases!

So, I am not satisfied with the answer β€œit just works” :-) I am asking for a more authoritative link.

+5
source share

All Articles