Hi Nick,

Please do not add new properties to Object.prototype.  It is for good
reason that Crockford's .beget method is not going to be added to
Object.prototype - that could break many existing codebases much as
you've found with Maps API v3.  Working around unexpected properties
on Object.prototype will slow down the various places we use Objects
as hash maps, as William points out.

I suggest using Object.beget: http://www.room51.co.uk/js/beget.html.

Cheers
Ben

On Tue, Aug 3, 2010 at 1:46 PM, Nick <gummyb...@gmail.com> wrote:
> I notice that when any property is added to Object.prototype (a
> variable or a function), Google Maps will fail to load the map.
>
> Here is an example demonstrating the problem: 
> http://dl.dropbox.com/u/9699560/map.html
>
> If you comment the line that says 'Object.prototype.pi = 3.1415;', the
> map will load.
>
> Web developer gives me this error:
>
> Error: Invalid value: [object Object] (Error in property <pi>: (a[d]
> is not a function))
> Source File: http://maps.gstatic.com/intl/en_us/mapfiles/api-3/1/8a/main.js
> Line: 16
>
> And Firebug says:
>
> a[d] is not a function
>
> I'm not sure what causes this, and I can't even begin to debug the
> minified Google code, so I was wondering if anyone had a fix or a
> workaround.
>
> Having access to Object.prototype is important, because I implement
> Douglas Crockford's Object.prototype.beget method (which will be added
> to the next ECMAScript version as Object.create).
>
> Thank you for the help!
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Google Maps JavaScript API v3" group.
> To post to this group, send email to google-maps-js-api...@googlegroups.com.
> To unsubscribe from this group, send email to 
> google-maps-js-api-v3+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/google-maps-js-api-v3?hl=en.
>
>

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

Reply via email to