Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8488193
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T21:27:55+00:00 2026-06-10T21:27:55+00:00

I am developing an iPhone application using PhoneGap and jQueryMobile, in my application I

  • 0

I am developing an iPhone application using PhoneGap and jQueryMobile, in my application I have two html pages, first is index.html page and second is mapView.html, now, my problem is when I open mapView.html from index.html using

function loadMap() {
        $.mobile.changePage( "mapView.html", { transition: "pop"} );
}

map is not loading. If I open mapView.html on any browser it works perfectly, even if I load mapView.html directly by changing
self.viewController.startPage = @"mapView.html";

in appDelegate class map loads on screen. Do anyone have any idea why map is not loading when I open it from another .html page?My PhoneGap version is 2.0.0
Thanks.

EDIT 1:mapView.html code

<!DOCTYPE HTML>
<html>
    <head>
        <title>Map Location</title>
        <link rel="stylesheet" href="jquery.mobile-1.1.1.min.css" />
        <script type="text/javascript" src="jquery-1.7.1.min.js"></script>
        <script type="text/javascript" src="jquery.mobile-1.1.1.min.js"></script>
        <script type="text/javascript" src="http://maps.google.com/maps/api/js?v=3&sensor=false&language=en"> </script>
        <script type="text/javascript">

            var demoCenter = new google.maps.LatLng(41,-87);

            var map;
            function initialize()
            {
                map = new google.maps.Map(document.getElementById('map_canvas'), {
                                          zoom: 7,
                                          center: demoCenter,
                                          mapTypeId: google.maps.MapTypeId.ROADMAP
                                          });
            }

            function addMarkers()
            {
                // perform your AJAX here. In this example the markers are loaded through the cityList array
                $.ajax({
                       type:'post',
                       url:'test.html',
                       data:'',
                       success:function(data)
                       {

                       // imagine that the data in this list
                       // will be retrieved from the AJAX response
                       // i used the cityList array just for testing
                       var cityList = [
                                       ['Chicago', 41.850033, -87.6500523, 1],
                                       ['Illinois', 40.797177,-89.406738, 2]
                                       ];

                       var marker, i;
                       var infowindow = new google.maps.InfoWindow();
                       for (i = 0; i < cityList.length; i++) 
                       {  
                       marker = new google.maps.Marker({
                                                       position: new google.maps.LatLng(cityList[i][1], cityList[i][2]),
                                                       map: map,
                                                       title: cityList[i][0]
                                                       });

                       google.maps.event.addListener(marker, 'click', (function(marker, i) {
                                                                       return function() {
                                                                       infowindow.setContent(cityList[i][0]);
                                                                       infowindow.open(map, marker);
                                                                       }
                                                                       })(marker, i));
                       }
                       }
                       });
            }

            $(document).ready(function() 
                              {
                              addMarkers();
                              });
            </script>
    </head>
    <body onload="initialize()">
        <div id="basic-map" data-role="page">
            <div data-role="header" data-theme="b">
                <h1>Map Location</h1>
                <a data-rel="back">Back</a>
            </div>
            <div data-role="content">   
                <div class="ui-bar-c ui-corner-all ui-shadow" style="padding:1em;">
                    <div id="map_canvas" style="height:350px;"></div>
                </div>
            </div>
        </div>      
    </body>
</html>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T21:27:57+00:00Added an answer on June 10, 2026 at 9:27 pm

    The $.mobile.changePage uses the jQuery Mobile AJAX functionality. jQuery Mobile loads only the code which is inside the first data-role=”page” element in the DOM.

    As stated in the jQuery Mobile docs , in jQuery Mobile, AJAX is used to load the contents of each page into the DOM as you navigate, and the DOM ready handler $(document).ready() only executes for the first page.

    Below you can find a working example which includes two pages, the navigation is performed through Ajax and the map is loaded inside the second page:

    Also note that you can perform a transition using rel=”external” or data-ajax=”false”. The usage of these attributes will cause a full page refresh without animated transition.

    Working Example:

    Instructions:

    • Create a folder
    • Create a file with name maps.js inside the folder
    • Create a file with name map-intro.html inside the folder
    • Create a file with name map.html inside the folder
    • Fill each one of the created files with the corresponding code which can be found below

    Add the below code inside the maps.js:

    function initialize() {
        var mapCenter = new google.maps.LatLng(59.3426606750, 18.0736160278),
        myOptions = {
            zoom:10,
            mapTypeId: google.maps.MapTypeId.ROADMAP,
            center: mapCenter
        },
        map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
    }
    
    $( document ).on( 'pageshow', '#map-page',function(event){
      initialize();
    });
    
    $( document ).on( 'click', '#map-anchor', function(event){
      event.preventDefault();
      $.mobile.changePage( "map.html", { transition: "flip" } );
    });
    

    Add the below code inside the map-intro.html:

    <!doctype html>
    <html lang="en">
       <head>
            <title>Map Intro Page</title>
            <link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.0/jquery.mobile-1.3.0.min.css" />
            <script src="http://code.jquery.com/jquery-1.8.2.min.js"></script>
            <script src="http://code.jquery.com/mobile/1.3.0/jquery.mobile-1.3.0.min.js"></script>
            <script type="text/javascript" src="http://maps.google.com/maps/api/js?v=3&sensor=false&language=en"></script>
            <script src="./maps.js"></script>
        </head>
        <body>
            <div id="map-intro-page" data-role="page">
                <div data-role="header">
                    <h1><a data-ajax="false" href="/">Map Example</a></h1>
                </div>
                <div data-role="content">   
                    <ul data-role="listview" id="my-list">
                        <li><a href="#" id="map-anchor">Go to Map</a></li>
                    </ul>
                </div>
            </div>
        </body>
    </html>
    

    Add the below code inside the map.html:

    <!DOCTYPE html> 
    <html> 
        <head> 
            <title>jQuery mobile with Google maps geo directions example</title>
            <link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.0/jquery.mobile-1.3.0.min.css" />
            <script src="http://code.jquery.com/jquery-1.8.2.min.js"></script>
            <script src="http://code.jquery.com/mobile/1.3.0/jquery.mobile-1.3.0.min.js"></script>
        </head>
        <body>
            <!-- /page -->
            <div data-role="page" id="map-page">
                <!-- /header -->
                <div data-role="header">
                    <h1>Map</h1>
                    <a data-rel="back">Back</a>
                </div>
                <!-- /content -->
                <div data-role="content" class="ui-bar-c ui-corner-all ui-shadow" style="padding:1em;">
                    <div id="map_canvas" style="height:300px;"></div>
                </div>
            </div>
        </body>
    </html>
    

    I hope this helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am developing an iPhone application using the PhoneGap Framework. Here I have to
I'm developing an iPhone application that have a TabBarController with two tabs. Each tab
Developing iphone application using makkit framework. I have got the map view integrated in
I am developing an iPhone application in which I have a page in which
I'm developing an application both for Iphone and Andriod using Phonegap. I came up
I have been developing an iphone application using a domain model, and have put
I am using MACOS for Developing the iPhone Application. I have made the repository
I'm developing a web application in iPhone using Phonegap. In this app, I want
I have developing an iPhone application using xcode 4 which is compatible with iOS
I'm developing one application for iphone using phone gap.I that I need to display

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.