Andrew is right that in general you should provide a link to your broken map
page. And your code is for Maps V3, not V2.

However, in this particular case, your posting the line of code that had the
problem is all that's needed, and in fact made it easier for me to spot the
problem. It actually has nothing to do with the Maps API; it's how you're
using jQuery.

document.getElementById(id) returns a reference to a DOM element.

$(selector) returns a reference to a *jQuery object*, not a DOM element.

The jQuery object is an array of DOM elements. You can access the elements
with the usual [0], [1], etc. notation. In the case of a #id selector, there
should be only a single element and you can use [0] to get to it.

So, for your code:

    var map = new google.maps.Map(
        document.getElementById("map_canvas"),
        myOptions
    );

the jQuery equivalent is:

    var map = new google.maps.Map(
        $("#map_canvas")[0],  // [0] gives the DOM element
        myOptions
    );

-Mike

On Sat, Jun 12, 2010 at 1:40 AM, Ned <[email protected]> wrote:

>
> Just following the tutorial
> http://groups.google.com/group/google-maps-api/post
>
> Why does this work:
>
> var map = new google.maps.Map(document.getElementById("map_canvas"),
> myOptions);
>
> .... But not the jQuery equivalent?....
>
>    var map = new google.maps.Map($("map_canvas"), myOptions);
>
> ..... the error message relates to mapTypeId... which is confusing
>
> Ned
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Google Maps API" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<google-maps-api%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/google-maps-api?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Maps API" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-maps-api?hl=en.

Reply via email to