trantuanvn / jquery-ui-map

Automatically exported from code.google.com/p/jquery-ui-map
0 stars 0 forks source link

Missing initialization step and error checking #7

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
It should be possible to initialize the plugin manually, rather than have 
initialization take place when the source file is parsed.

This is critical because web applications must sometimes run offline; if the 
Google Maps API is unavailable (since it cannot be used offline), there needs 
to be a way for the app to gracefully degrade. Currently, this plugin assumes 
that that the google.maps object always exists.

Original issue reported on code.google.com by kpozin@gmail.com on 24 May 2011 at 3:23

GoogleCodeExporter commented 8 years ago
If you use it offline you could just add 
if ( google.maps ) {
    // the plugin code here
}

About "initialize the plugin manually" - I need more explanation. 

Original comment by johansalllarsson on 24 May 2011 at 5:20

GoogleCodeExporter commented 8 years ago
I meant that the code in jquery.ui.map.js that extends $.fn and creates the 
ui.gmap object should only be executed when the client code calls some init() 
method, rather than being wrapped in a self-executing function. Otherwise it 
can throw a reference error on startup because google and google.maps are 
undefined, and can break unrelated click, rightclick, dblclick, etc. event 
handlers in the application because of the reference to google.maps.MVCObject 
in addEventListener.

I understand that a user of the library can modify the source file as needed to 
put in the needed checks, but ideally, library code should not easily break 
unrelated functionality. Deferring the plugin initialization to a manually 
called method would allow client applications to avoid these problems.

Original comment by kpozin@gmail.com on 24 May 2011 at 5:46

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
You are correct that the plugin shouldn't break any jquery core events if you 
are missing the google maps source. Thanks for pointing this out :). I've fixed 
that in the trunk. With this fix there is no need for any init method.

Original comment by johansalllarsson on 25 May 2011 at 3:28