setMapTypeId not working with custom map

333 views
Skip to first unread message

24/7

unread,
Sep 7, 2011, 8:17:00 AM9/7/11
to google-map...@googlegroups.com
I have a set of different map types (styles). As you can see in the simplified example [1], 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. 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.

Any help is highly appreciated.

Thanks in advance!

24/7

unread,
Sep 7, 2011, 11:44:00 AM9/7/11
to google-map...@googlegroups.com
As a follow up I added 

console.log( my_map.mapTypes.<?php echo strtolower( $type ); ?> );

to see if every map type is available onClick. And it is available. I really got no clue what could cause the map tiles go plain'n'empty grey onClick my custom map type/style.

Hope someone got some idea to get around this - pretty strange - behavior.

24/7

unread,
Sep 7, 2011, 12:41:22 PM9/7/11
to google-map...@googlegroups.com
After "playing" (to use a nice word) around with it for more than just some hours, I switched to a DomListener [1]. Sadly to say, but it's the same result: My map gets grey & empty. I debugged each and everything (see commented calls to console.log(); ) and see that the objects are there and filled. I'm close to saying: This must be a bug!


[1] Example incl. DomListener: http://pastie.org/2498053

24/7

unread,
Sep 7, 2011, 1:08:17 PM9/7/11
to google-map...@googlegroups.com
So after several hours of doing things the way the API described, I switched to simple string that I passed to set the map type and everything's fine [1]

24/7

unread,
Sep 7, 2011, 1:14:39 PM9/7/11
to google-map...@googlegroups.com
Accidently posted the wrong code. This [1] one works.

Chris Broadfoot

unread,
Sep 7, 2011, 8:22:59 PM9/7/11
to google-map...@googlegroups.com
Hi,

You shouldn't need to trigger the 'resize' event.

Otherwise, that code looks fine (though I don't know PHP very well). In future, could you post a link instead of PHP code? It makes it much easier for us to debug.

On Thu, Sep 8, 2011 at 3:14 AM, 24/7 <24...@gmx.net> wrote:
Accidently posted the wrong code. This [1] one works.

--
You received this message because you are subscribed to the Google Groups "Google Maps JavaScript API v3" group.
To view this discussion on the web visit https://groups.google.com/d/msg/google-maps-js-api-v3/-/2LJ2F_5X8jMJ.

To post to this group, send email to google-map...@googlegroups.com.
To unsubscribe from this group, send email to google-maps-js-a...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-maps-js-api-v3?hl=en.

Reply all
Reply to author
Forward
0 new messages