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 7033255
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:02:33+00:00 2026-05-28T01:02:33+00:00

I created a simple Google Maps webpage using Javascript. I parse an XML file

  • 0

I created a simple Google Maps webpage using Javascript. I parse an XML file and display a series of markers on a map of the Korean city I live in. Works great in all browsers on a windows machine but doesn’t work at all when I access the same page on my Android phone. I get all the html of the web page, including menus, ads, etc, but the map is not even shown at all.
Hooked the phone up to Eclipse and checked the log, but no errors I could see. Anyone know any reason why Android would have trouble showing a Google Maps page?

If you want to see the code, it’s here:
http://ulsanonline.com/ulsanmap.php
and the javascript I use to populate the map is below:

function detectBrowser() {
  var useragent = navigator.userAgent;
  var mapdiv = document.getElementById("map_canvas");

  if (useragent.indexOf('iPhone') != -1 || useragent.indexOf('Android') != -1 ) {
    mapdiv.style.width = '100%';
    mapdiv.style.height = '100%';
  } else {
    mapdiv.style.width = '600px';
    mapdiv.style.height = '800px';
  }
}

var markersArray = new Array();
var map;

function initialize() {
    var latlng = new google.maps.LatLng(35.543401,129.340954);
    var myOptions = {
      zoom: 12,
      center: latlng,
      mapTypeId: google.maps.MapTypeId.ROADMAP
    };
    map = new google.maps.Map(document.getElementById("map_canvas"),
        myOptions);
    detectBrowser();

    var dine_image = new google.maps.MarkerImage(
      '/Maps/dine.png',
      new google.maps.Size(50,50),
      new google.maps.Point(0,0),
      new google.maps.Point(25,50)
    );
    var drink_image = new google.maps.MarkerImage(
      '/Maps/drink.png',
      new google.maps.Size(50,50),
      new google.maps.Point(0,0),
      new google.maps.Point(25,50)
    );

    var shadow = new google.maps.MarkerImage(
     '/Maps/shadow.png',
     new google.maps.Size(78,50),
     new google.maps.Point(0,0),
     new google.maps.Point(25,50)
    );


   // read the xml file
   if (window.XMLHttpRequest)  {// code for IE7+, Firefox, Chrome, Opera, Safari
 xmlhttp=new XMLHttpRequest();
   }
   else  {// code for IE6, IE5
     xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
   }

   xmlhttp.open("GET","/uoplaces.xml",false);
   xmlhttp.send();
   xmlDoc=xmlhttp.responseXML; 
   xml=xmlDoc.getElementsByTagName("place");

   // parse xml
   for (i=0; i < xml.length; i++) {
       var name = xml[i].getElementsByTagName("name")[0].childNodes[0].nodeValue;
       var type = xml[i].getElementsByTagName("name")[0].getAttribute("category");
       var link = xml[i].getElementsByTagName("link")[0].childNodes[0].nodeValue;
       var lat = xml[i].getElementsByTagName("lat")[0].childNodes[0].nodeValue / 1000000;
       var long = xml[i].getElementsByTagName("long")[0].childNodes[0].nodeValue / 1000000;


       var contentString = '<div id="content">'+
         '<h1 id="firstHeading" class="firstHeading">' + name + '</h1>'+
         '<a href=' + link + '>' + 'More Info' + '</a>'+
         '</div>';


       var infowindow = new google.maps.InfoWindow();

       var myLatlng = new google.maps.LatLng(lat,long);
       if (type == "restaurant") {
      var marker = new google.maps.Marker({
             position: myLatlng,
             map: map,
             type: type,
             icon: dine_image,
             shadow: shadow,
          html: contentString
      });
   }
   else {
      var marker = new google.maps.Marker({
         position: myLatlng,
         map: map,
         type: type,
         icon: drink_image,
         shadow: shadow,
         html: contentString
          });
       }

       google.maps.event.addListener(marker, 'click', (function(marker, i) {
          return function() {
            infowindow.setContent(this.html);
            infowindow.open(map, marker);
          }
       })(marker, i));

       markersArray.push(marker);

    } // parse

    for (i in markersArray) {
      markersArray[i].setMap(map);
    }

} //end function initialize



// Removes the overlays from the map, but keeps them in the array
function clearOverlays() {
  if (markersArray) {
    for (i in markersArray) {
      markersArray[i].setMap(null);
    }
  }
}

// Shows any overlays currently in the array
function showOverlays(category) {
  if (markersArray) {
    for (i in markersArray) {
      if (markersArray[i].type == category) {
         markersArray[i].setMap(map);
      }
    }
  }
}

I’ve actually created an Android app using the same GoogleMaps API, data and purpose, and it works fine, too. It’s just the Android browser or Firefox on Android that doesn’t work which makes me think it might be with the XMLHTTPREQUEST done in the initialize() function.

Any ideas?

  • 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-05-28T01:02:34+00:00Added an answer on May 28, 2026 at 1:02 am

    In case anyone else runs into this, the problem was with my CSS. I had set the iPhone or Android % but not size. If I had a desktop/laptop browser the size was set but if I had a phone browser the size wasn’t and setting a % of something not set gave me no map_canvas to draw on.

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

Sidebar

Related Questions

I'm struggling trying to cluster 50 markers using the markerclusterer v3 with Google maps
I have created a simple app which shows a Google Map. I am testing
I have created a simple Google chrome extension that overrides CSS classes using the
Could someone help me on this, I have created simple web services using axis2
How to manually create Friendly URLs? (PHP) So I have created simple php file
I have created a simple map app that shows the local garage sales in
I'm using the Google Maps API and would like it to render a very
I have a simple object that get's geocoding data from the Google Maps API
I've made a very simple app that just displays a Google map. However, it
How can i use MapKit and Google Maps to build a simple navigation APP

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.