A working dynamically loaded google map api v3
just as a tip for someone looking to load google map dynamically in jqm 1.1.1. hope this help ! Cheers !
- in your index.html file:
- <div id="map_canvas"></div>
- in your js file:
- $('#map_canvas').live("pageinit", function() {
- $('#map_canvas').css({'width':$(window).width(),'height':$(window).height()});
-
- });
- $('#location').live("pageshow", function() {
- if(window.navigator.onLine){
- $.getScript("http://www.google.com/jsapi").done(function(script, textStatus) {
-
- google.load("maps","3", {"other_params":"sensor=false","callback":"loadJqueryUiMap"});
-
- });
-
- } else {
-
- // alert user and doesn't need to continue
-
- }
- });
- function loadJqueryUiMap(){
- $.getScript("jquery/jquery.ui.map.full.min.js").done(function(script, textStatus) {
- loadMap();
- });
- }
- function loadMap(){
- var map = $('#map_canvas');
- map.gmap('destroy');
-
- var latLng = new google.maps.LatLng('1.222222','110.333333333');
- map.gmap({'center': latLng, 'zoom': 15, 'disableDefaultUI': true, 'streetViewControl': true,'callback': function() {
-
- var self = this;
-
- self.addMarker({'position': this.get('map').getCenter() }).click(function() {
-
- self.openInfoWindow({ 'content': 'Awesome Google Map' }, this);
- });
-
- }});
-
- map.gmap('refresh');
- }