leossmith leossmith - 5 months ago 29
MySQL Question

MapQuest POIs from database in flex

So im basicaly trying to generate pois on mapquest from a database. i have all i need the flex application is set and the database working but i kind of got stack on the process. does anyone have any examples or know of any tutorials i can use?even if it is for google maps flex api it would be really helpful.thanx

Answer

ok so basicaly the problem was that all the services must run on the creation of the new view or they wont run correctly on the functions. solving that let me continue with my solution which i will provide as a help for any new developers on mapquest.

private function createPois():void
        {

            [Embed (source='views/mapicons/hotel.png')] var hotelImg:Class;

            for (var i:int = 0; i <countResult.lastresult-1 ;i++)
            {
                var latLng:LatLng;
                latLng.setLatLng(getAllMarkersResult.lastResult[i].lat,getAllMarkersResult.lastResult[i].lng);
                var myPOI:Poi = new Poi(latLng);

                var icon:MapIcon = new MapIcon();
                icon.setImage(new hotelImg(),64,64);

                myPOI.label = getAllMarkersResult.lastResult[i].name + " - Academic Building";
                myPOI.labelVisible = false;
                myPOI.icon=icon;
                myPOI.rolloverAndInfoTitleText = getAllMarkersResult.lastResult[i].name;
                myPOI.rolloverContent = getAllMarkersResult.lastResult[i].name;
                myPOI.infoContent = (getAllMarkersResult.lastResult[i].description);

                dbColl.add(myPOI);
            }
        }

The logic is really simple. I create a loop which will run for the number of entries in the database and i use the countResult php service to get this number. From there the only thing i had to do is follow the add poi methodology for mapquest but giving data from the database to all the variables. In order to do that i used the getall methodo and the token lastresult which saves all the data. I believe my code is pretty straight forward and it will help new developers for Flex Mobile and MapQuest