jquerymobile google maps without ajax set to false

Posted: February 3, 2012 in web

The last two functions below did the trick.

                    
                      var jsonpark = " + json + @";

                    var start = new google.maps.LatLng(29.651636, -82.324827); 

                    var infow;
                    var map;
                    var iterator = 0;
                    var mapOptions;

                      function initialize() {
                          mapOptions = {
                          zoom: 10,
                          mapTypeId: google.maps.MapTypeId.ROADMAP,
                          center: start
                        };

                        map = new google.maps.Map(document.getElementById('map_canvas'),
                                mapOptions);
	                    drop();
                      }

                      function drop() {
                        for (i = 0; i < jsonpark.length; i++) 
                        {
                                setTimeout(function() {
                                    addMarker();
                                }, i * 155);
                        }
                      }
                       function BuildParkInfoWindow(ParkItem)
                      {
                            var Final = Array();	
            				for (x = 0; x < ParkItem.Activity.length; x++) {
					            Final.push(ParkItem.Activity[x].Title);
			                }
            				var activity = Final.join(', ');

                            var html = '<div id="map_info"><div class="map_info_title"><strong>' + ParkItem.Title + '</strong></div>';
                            html += '<div class="map_info_address"><a target="_blank">' + ParkItem.Address + '</a></div>';
                            html += '<div class="map_info_activies">' + activity + '</div>';
		                    return html;
                      }

                      function addMarker() {

	                    var park = jsonpark[iterator];
                        

	                    if( (park.Latitude) &amp;&amp; (park.Latitude != '' &amp;&amp; park.Longitude != '')){
		                    console.log(park.Latitude);
		                    var contentString = BuildParkInfoWindow(park);
		                    var infowindow = new google.maps.InfoWindow({
			                    content: contentString,
                                maxWidth:355
		                    });  

		                    var x = new google.maps.Marker({

		                      position: new google.maps.LatLng(park.Latitude, park.Longitude),

		                      map: map,

		                      draggable: false,

		                      animation: google.maps.Animation.DROP,

		                      title: park.Title

		                    });

		                    google.maps.event.addListener(x, 'click', function() {

		                      if(typeof infow != 'undefined')

			                    infow.close();

		                      infowindow.open(map,x);

			                    infow = infowindow;

		                    });	
	                    }	
	                    iterator++;
                      }
                    
                        $('.page-map1').live('pagecreate', function() {

                            initialize();
                        });
$('.page-map1').live('pageshow',function(){

            google.maps.event.trigger(map, 'resize');
            map.setOptions(mapOptions); 

        });
                    
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s