Skip navigation
Currently Being Moderated

Google Maps Not Working On iphone

Oct 5, 2010 9:07 AM

I created a demo app using the Google Maps API for flash that displays your currently location on a map. I published it as a .swf and it worked (without displaying the current location, no geolocation support). I published it as a .apk for an Android device and it worked as well (Displayed current location, available geolocation support). I then published it as a .ipa for an iphone and itouch and it didn't work properly. When the .ipa app launches it displays the ui properly (graphics, labels etc.) and it seems to add the goolge map object to the screen but it only shows up as a grey box.I'm not exactly sure if this is an issue with the iphone packager, the google maps api for flash or something else. Would anyone have insight on this? Thanks in advance.

 
Replies
  • Currently Being Moderated
    Oct 5, 2010 9:18 AM   in reply to AlexG10

    I ran into problems trying to work SWFs into my app.  I had much better luck publishing them as SWCs and then linking them in.

     
    |
    Mark as:
  • Currently Being Moderated
    Oct 5, 2010 9:20 AM   in reply to David Coletta, Noteflight

    David, that means you've got Google Maps working on the iPhone (ipa)?

     
    |
    Mark as:
  • Currently Being Moderated
    Oct 5, 2010 9:22 AM   in reply to Christian Pugliese

    No, not Google Maps. 

     
    |
    Mark as:
  • Currently Being Moderated
    Oct 12, 2010 9:07 AM   in reply to AlexG10

    Hey AlexG10,

     

    I have Google Maps working on my app, but its not the flash version of the maps as it does exactly what you're describing - displaying a gray box with no map.  What I did as a work around was to call the static map api that Google offers.  Basically passing either an address or lat/long coordinates and getting an image back.  You can customize to display markers, zoom level, detail, etc.

     

    Here is a screenshot from my app (still debugging local storage, but the app works great):

    photo (1).PNG

     
    |
    Mark as:
  • Currently Being Moderated
    Oct 12, 2010 9:41 AM   in reply to en3pnur

    That sounds amazing, do you know if can you slide/pan the map around?

    would you mind post you code work around for us?

     

    cheers

     
    |
    Mark as:
  • Currently Being Moderated
    Oct 12, 2010 10:06 AM   in reply to Christian Pugliese

    Thanks Christian,

     

    You won't be able to pan and zoom but you can load the static images pretty quickly.  Below are the general requests to the static api for google.  Basically what I'm doing is, calling the maps api to get my current location or a location provided by an address.  Once I get the xml response that I have a valid location, I then load that location's static image, passing the lat/long pair or the address returned by the xml.

     

    Example code:

     

    var  url:String = "";
    var  imgLoader:Loader = new Loader();
         mapHolder.addChild(imgLoader);
    
    var  coordsXML:XMLList = new XMLList();
    var  mapLat;
    var  mapLong;
    
    var  myLocation:Geolocation = new Geolocation();
         myLocation.addEventListener(StatusEvent.STATUS, getLocationStatus);
         myLocation.addEventListener(GeolocationEvent.UPDATE, getLocationStatus);//gets current location of iphone
    
    function getLocationStatus(e:GeolocationEvent)
    {
         mapLat = e.latitude;
         mapLong = e.longitude;
         loadDataXML("http://maps.googleapis.com/maps/api/geocode/xml?latlng=" + mapLat + "," + mapLong + "&sensor=true", showCurrentAddress);
         myLocation.removeEventListener(GeolocationEvent.UPDATE, getLocationStatus);
    }
    
    function showCurrentAddress(e:Event)
    {
         coordsXML = new XMLList(e.target.data);
         if(coordsXML..status == "OK")
         {
              mapLat = coordsXML..lat[0];
              mapLong = coordsXML..lng[0];     
              addressTxt.text = mapLat + ", " + mapLong;
              url = "http://maps.google.com/maps/api/staticmap?zoom=16&size=" + mapHolder.width + "x" + mapHolder.height + "&maptype=roadmap&markers=color:blue|label:A|" + mapLat + "," + mapLong + "&sensor=true";
              imgLoader.load(new URLRequest(url));
              
         }else
         {
              addressTxt.text = "Couldn't find address";
         }
    }
    
    //loading xml data
    function loadDataXML(url:String, handler:Function)
    {
         var listener = handler;
         var urlRequest:URLRequest = new URLRequest(url);
         var urlLoader:URLLoader = new URLLoader();     
             urlLoader.addEventListener(Event.COMPLETE, listener, false, 0, true);
             urlLoader.load(urlRequest);
    }

     

    Not really "plug-n-play" code but just a snippet for the geolocation stuff.

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 29, 2011 3:12 PM   in reply to en3pnur

    this is disheartening..  while the static map image is a work around, it doesn't work for my app as my users will need to move around the map.  Is there another map api that people can use?

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 30, 2011 12:12 PM   in reply to AlexG10

    i actually was looking into the yahoo maps, but the extension they have for download seems to only be for cs3, i am using cs5 obviously and can't find the class files anywhere.. i installed the extension but keep getting the message that com.yahoo..... can not be found.. i looked everywhere on my machine but it doesn't seem to have installed the classes anywhere.

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 30, 2011 1:02 PM   in reply to AlexG10

    mxp..

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 31, 2011 9:00 AM   in reply to erikliddell

    Ok i finally got it working.. silly me, i had to pull an instance of the component out of the library, on to the stage and then delete it.. then bam, everything was a ok.. 

     

    Question though:  below you will see my old code that i used for the google maps api.  essentially this code is placing bus stop signs on the map using a custom marker from my library.  I am having some trouble converting this to the yahoo api as it seems they handle it differently.  I don't suppose you could be so kind as to help me translate this to the yahoo way?  I cant seem to find a way to clear the overlays in yahoo as this function gets called at different times, and the way to use a library item with yahoo, seems to use a linkage id, so i am unsure how to pass variable to each one like i am doing in the first part of my for loop?

     

    function loadBusStops(stops:Array,myXML:XML,routeTag:String,busNum:String):voi d

    {

         map.clearOverlays();

     

         for (var bs:int=0; bs<stops.length; bs++)

         {

              var stopSign:busStopSign = new busStopSign();

              stopSign.routeTag = routeTag;

              stopSign.busNum = busNum;

              stopSign.stopID = stops[bs];

              stopSign.stopName = getStopName(myStop,myXML);

              stopSign.myRoot = this.parent;

     

              var myName:String = getStopName(myStop,myXML);

              var myStop:String = stops[bs];

              var newLat:Number = getStopLat(myStop,myXML);

              var newLon:Number = getStopLon(myStop,myXML);

              var stopName:String = getStopName(myStop,myXML);

     

              var stopMarker:Marker = new Marker(new LatLng(newLat,newLon),

              new MarkerOptions({icon:stopSign}));*/

              map.addOverlay(stopMarker);

            

         }

     

    }

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points