Jonathan Schofield
Jonathan Schofield

Reputation: 308

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?

Upvotes: 4

Views: 4321

Answers (1)

Recep Karabıçak
Recep Karabıçak

Reputation: 2083

try this:

map.setMapTypeId(google.maps.MapTypeId.HYBRID);

Upvotes: 12

Related Questions