Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google maps v3: syntax to change mapType on click event

I have a v3 Google map initialised as a ROADMAP that I want to change to a HYBRID map on a particular click event being handled by a jQuery function:

$('#cft').click(function() {
  map.setCenter($cft);
  map.setZoom(18);
  map.setMapType(HYBRID);
  return false;
});

On click the map recenters and zooms as required but the mapType remains a ROADMAP so clearly this syntax doesn't work!

Is there a method like the above that does, or do I have to initialise a new map?

like image 994
Jonathan Schofield Avatar asked Dec 17 '22 14:12

Jonathan Schofield


1 Answers

try this:

map.setMapTypeId(google.maps.MapTypeId.HYBRID);
like image 88
solidrevolution Avatar answered Jan 21 '23 05:01

solidrevolution