Open GoogleCodeExporter opened 9 years ago
I am still using ui-map 2.0 and trying to load google.maps dynamically due to
network connection on mobile device is not always available.
I try to load jquery-ui-map-2.0.js dynamically in the callback of finishing
loading google map api js. But it gets script error when calling:
$('#map_canvas').gmap( {'center' : '12.34, 56.334'} );
Below are code snippets:
function addScriptToHead( stSrc) {
var s = document.createElement("script");
s.type = "text/javascript";
s.src = stSrc;
// Use any selector
$("head").append(s);
}
....
addScriptToHead( "http://maps.google.com/maps/api/js?sensor=false&callback=googlemaps_init"); //2012.12.18 works and googlemaps_init() is called.
function googlemaps_init(){
//2012.12.19 now it is safe to load ui-map widget.
addScriptToHead( "jquery.mobile/jquery.ui.map-2.0.min.js" ); //2012.12.18 load it after gmap
}
--- after all above is executed. calling the following and get error
$('#map_canvas').gmap({ 'center': '-31.952,115.857' });
Original comment by george.g...@gmail.com
on 19 Dec 2012 at 3:27
This script shouldn't fail if Google Maps it's not loaded.
Changing
if ( google.maps && this[0] instanceof google.maps.MVCObject ) {
to
if ( typeof("google") != 'undefined' && google.maps && this[0] instanceof google.maps.MVCObject ) {
In
http://code.google.com/p/jquery-ui-map/source/browse/trunk/ui/jquery.ui.map.js#3
38
and
http://code.google.com/p/jquery-ui-map/source/browse/trunk/ui/jquery.ui.map.js#3
51
fies this.
Original comment by martin.s...@gmail.com
on 16 Jun 2014 at 2:40
Original issue reported on code.google.com by
raksha.a...@gmail.com
on 25 Jun 2012 at 6:57