12 Replies Latest reply on Oct 8, 2007 10:50 AM by FlashForumName

    Mapping with Flash

    FlashForumName Level 1
      Hey all. I am thinking about creating some kind of mapping application using Flash. I already have done a little bit, using the bitmapdata class along with a mysql database to create some small mapping apps. I draw everything pixel by pixel and do my queries based on what pixel they click on etc. I was just wondering if someone could give me some advice on whether or not there is a better way to create flash map type apps. I have been hearing about this Flex product lately and was wondering if that's the best route to take.

      Any advice would be appreciated.
        • 1. Re: Mapping with Flash
          kglad Adobe Community Professional & MVP
          where's your application going to be located, online or local to the user/ what does it do?
          • 2. Mapping with Flash
            FlashForumName Level 1
            It will be online. It will have a variety of queries based upon county such as population statistics, area, perimeter, etc. I can do those ok since it's just a simple hit the database once and retrieve the value.

            But, I'd like to color the counties based on population. I've been able to do this just fine using the bitmapdata class but offsite it's quite slow. I am not sure if this is because there are 99 counties and for each county I query the database of 84k elements, then draw, then move to next county, hit, draw, repeat till done. So, I'm not sure if that's what is causing it to be slow and if I'd be better off doing one query and one draw or if there is a better method. Or, if there is a better way to be doing it entirely.
            • 3. Re: Mapping with Flash
              kglad Adobe Community Professional & MVP
              is this as2 or as3? if your counties were movieclips, you wouldn't need to loop through each pixel in the county. are they?
              • 4. Re: Mapping with Flash
                FlashForumName Level 1
                It's as3. The counties are not movieclips. The counties are shown through a jpg which is loaded into a loader. Based upon where they click on the loader, I can use the x,y positions to run a query to the database which has an entry for each pixel that denotes the county. Yet, this makes me have 83,000+ entries just for one state where if there were some way to draw the clips separately I could get by with 99 entries. I suppose this leads me to ask how could I create these movieclips in the polygon shapes of the counties so I'd only have 99 things to keep track of instead of each pixel through the bitmapdata class? Assuming that is a better way to do it which it sounds like to me.
                • 5. Re: Mapping with Flash
                  clbeech Level 3
                  wow! for sure, that's alot of info to pull! Like kg is saying you could draw an overlay of each county in flash as a MC, then query the DB for the population for each, and use the colorTransform class to change the color. then use another MC or panel to show the stats onRollOver. this would be much, much faster.
                  • 6. Re: Mapping with Flash
                    kglad Adobe Community Professional & MVP
                    is each county a separate jpg?
                    • 7. Re: Mapping with Flash
                      FlashForumName Level 1
                      quote:

                      Originally posted by: kglad
                      is each county a separate jpg?


                      No. I only have the one jpg which has all the counties shown on it in the same picture. I have been using the database to distinguish between counties based upon the 1 jpg.
                      • 8. Re: Mapping with Flash
                        FlashForumName Level 1
                        quote:

                        Originally posted by: clbeech
                        wow! for sure, that's alot of info to pull! Like kg is saying you could draw an overlay of each county in flash as a MC, then query the DB for the population for each, and use the colorTransform class to change the color. then use another MC or panel to show the stats onRollOver. this would be much, much faster.


                        I thought about doing something like this. Creating a bitmapdata object for each county and then creating a bitmap for each bitmapdata object and adding the different events to the bitmap object. Yet, whenever you create a bitmapdata class object, they are not of a polygon type shape. It has a width, height but these counties are not always square type shapes. So, this lead me to believe I'd have problems with overlapping objects where one county was a square and another wasn't unless I am missing something which is quite possible.

                        Is this the kind of solution you were heading towards?
                        • 9. Re: Mapping with Flash
                          kglad Adobe Community Professional & MVP
                          if there's no way to distinguish counties except via your database, you're stuck. (who made that database?)

                          you should seriously consider using a different jpg. one that already indicated counties by color differences would solve a lot of problems.
                          • 10. Re: Mapping with Flash
                            FlashForumName Level 1
                            quote:

                            Originally posted by: kglad
                            if there's no way to distinguish counties except via your database, you're stuck. (who made that database?)

                            you should seriously consider using a different jpg. one that already indicated counties by color differences would solve a lot of problems.


                            The database was some exported thing I was given from a piece of software a colleague uses...fun I know! Anyway. I did a little searching and found something kind of similar to what I am wanting to create although this example is way more complex. When I look at it there is one thing I'm not sure of. How do they first construct the image and break it down into counties. Here is a link of what I am talking about:

                            http://www.geoclip.fr/an/p24_atlas.php

                            The top right USA map for example. When you mouse over the counties, it changes the alpha/color or whatnot and gives you a bit of data. How do you think they are able to tell what county it is and change the color accordingly? We'd really like to do something similar to just that but with the pixel by pixel data they gave me, going through and coloring the whole thing is slow. Yet, in this link I found the coloring is nearly instant. Any ideas?
                            • 11. Re: Mapping with Flash
                              clbeech Level 3
                              well, not exactly, although you could use the transparecy property of the the BitmapData class. What I was really saying though is that it would be easier to just pull the map jpg into Flash, then on a separate layer, use the drawing tool to 'trace' and fill the county shapes, convert each to a MC symbol and apply methods to each the query the DB for the related info. Although I don't know the structure of you DB, so it hard to tell how this would work for you, and the example you've given above, is indeed calcing the draw.

                              giving the map the rollOver functions and linking the counties to info would be pretty simple using the type of method I've described, but it can of course be achieved with the system you've been working on, but with a lot more coding.
                              • 12. Re: Mapping with Flash
                                FlashForumName Level 1
                                quote:

                                Originally posted by: clbeech
                                well, not exactly, although you could use the transparecy property of the the BitmapData class. What I was really saying though is that it would be easier to just pull the map jpg into Flash, then on a separate layer, use the drawing tool to 'trace' and fill the county shapes, convert each to a MC symbol and apply methods to each the query the DB for the related info. Although I don't know the structure of you DB, so it hard to tell how this would work for you, and the example you've given above, is indeed calcing the draw.

                                giving the map the rollOver functions and linking the counties to info would be pretty simple using the type of method I've described, but it can of course be achieved with the system you've been working on, but with a lot more coding.


                                Ah yeah. We've done something similar to that for a puzzle. Perhaps, that is the best solution. Thanks for the input.