Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6539817
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T10:54:15+00:00 2026-05-25T10:54:15+00:00

I have a set of different map types (styles). As you can see in

  • 0

I have a set of different map types (styles). As you can see in the simplified example, I try to switch the map types with an onClick event.

This works great for the default – by google.maps provided – styles. But when I try to switch to my custom style, I have a delay of ~2-3 seconds (local environment) and then get a completely grey map (nothing on the tiles).

I know that the map style itself works (not the same as in the linked example), because it’s my initial map style. So only the switch back to my custom style is not working. Sadly I get nothing in the console and don’t know how I could debug this.

<?php
// Inside the init(); function:
?>
var custom_style = [
     {
         featureType: 'water'
        ,stylers: [
             { hue: "#009ee0" }
            ,{ saturation: 100 }
            ,{ lightness: 0 }
         ]
     }
];
var CUSTOMMAPTYPE = new google.maps.StyledMapType( 
    custom_style, 
    // Options:
    { 
        alt: "Show Custom style",
        name: "custom" 
    } 
);

<?php
// Inside the view
$map_types = array(
     'Roadmap'
    ,'Terrain'
    ,'Satellite'
    ,'Hybrid'
    ,'CustomMapType'
);
foreach ( $map_types as $index => $type )
{
    ?>
    <span 
        class="map-type" 
        onClick="
                my_map.setMapTypeId( google.maps.MapTypeId.<?php echo strtoupper( $type ); ?> );
                // This is funny: I can access all mapType objects without a problem:
                console.log( my_map.mapTypes.<?php echo strtolower( $type ); ?> );
            " 
        id="<?php echo strtolower( $type ); ?>"
    >
        <?php echo $type; ?>
    </span>
    <?php
}
?>

Any help is highly appreciated.

Thanks in advance


EDIT:

Here’s something other I tried (from inside my init(); fn, that does the setup for the map):

// The map type control DOM/UI Element
var map_type_controls = document.getElementsByClassName( 'map-type' );

// using jQuery to add a DOM listener function for click events to the UI elements:
jQuery.each( map_type_controls,  function() {
    google.maps.event.addDomListener( this, 'click', function() {
        var control_id = jQuery( this ).attr( 'id' );
        var control = control_id.toUpperCase();

                // uncomment to debug:
                // Shows all map type control DOM element correct
        // console.log( control );
                // Shows all registered mapType objects incl. the custom one correct:
                // console.log( my_map.mapTypes );

        my_map.setMapTypeId( google.maps.MapTypeId[ control ] );

                // Per recommendation - doesn't help
        google.maps.event.trigger( atlas_map, "resize" );
    } ); 
} );
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T10:54:16+00:00Added an answer on May 25, 2026 at 10:54 am

    Normally when you modified a property of a map, let’s say a new coordinates or a zoom, even if you change the size of the container (div), you should trigger the event called resize it’s the only way to avoid this problem, now, i don’t know if this works when you change the type of the map but you should try, the code it’s the following:

        google.maps.event.trigger(map, "resize");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I have two custom complex types like this (oversimplified for this example): public
I have a set of different interfaces and I need to give them access
I have a set of stylesheets with different colour options. I have created a
We have developers working in different geographic locations and we want to set up
I have installed two different version of rails in same gem set. When I
I have code in javascript which get keycodes of different keys and set it
I have a table that has three different date columns, so I set each
I am adding musicCD information to a set. I have two different functions for
I have 2 different object types stored in RavenDb, which are a parent/child type
I have a form I'm trying to set up ... Users can have many

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.