12 Replies Latest reply: Jan 31, 2011 9:00 AM by erikliddell RSS

    Google Maps Not Working On iphone

    AlexG10 Community Member

      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.

        • 1. Re: Google Maps Not Working On iphone
          David Coletta, Noteflight Community Member

          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.

          • 2. Re: Google Maps Not Working On iphone
            Christian Pugliese Community Member

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

            • 4. Re: Google Maps Not Working On iphone
              en3pnur Community Member

              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

              • 5. Re: Google Maps Not Working On iphone
                Christian Pugliese Community Member

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

                would you mind post you code work around for us?



                • 6. Re: Google Maps Not Working On iphone
                  en3pnur Community Member

                  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();
                  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));
                            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);


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

                  • 7. Re: Google Maps Not Working On iphone
                    erikliddell Community Member

                    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?

                    • 8. Re: Google Maps Not Working On iphone
                      AlexG10 Community Member

                      You can try the yahoo maps flash api. Seems to do the job. It would be nice

                      if Google maps flash api accounted for the iphone packager.

                      • 9. Re: Google Maps Not Working On iphone
                        erikliddell Community Member

                        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.

                        • 10. Re: Google Maps Not Working On iphone
                          AlexG10 Community Member

                          Did you try to install YahooMap-0.9.4.swc or YahooMap-0.9.4.mxp

                          • 12. Re: Google Maps Not Working On iphone
                            erikliddell Community Member

                            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):void




                                 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}));*/