38 Replies Latest reply on Nov 6, 2009 6:16 AM by MeadowRyan

    zooming to certain map locations

    MeadowRyan

      Can someone give me some pointers as far as how to zoom into(hence zooming the map outward) set locations on a map, yet only those locations. I have a script which will zoom to your mouse location and also if I set the specific x and y, but still zooms when clicking on any other spot.

       

      Long story short how do I zoom to only a set location and nothing else within a map/image.

       

       

      thanks for any help provided as Im really stuck here.

        • 1. Re: zooming to certain map locations
          robdillon Most Valuable Participant

          One way to do this would be to place target movieClips on the map, then test to see if the user's cursor is over one of those targets allow the zoom function to run on that location.

          • 2. Re: zooming to certain map locations
            MeadowRyan Level 1

            could you give me an example as to how to check currently Im using this script(which isn't mine) which zooms based on the mouse location, it works great, but Im trying to get it to zoom only to set points: I may have to bag this script all together....

             

            thanks for any help

             

             

            onClipEvent(load)
            {
                var i = 0; 
            }


            onClipEvent (mouseDown) {
                if (i>0) {
                    return;
                }

             

                zoom = true;
                dir == 1 ? (dir=-1) : (dir=1);
                if (dir == 1) {
                    pt = {x:_root._xmouse, y:_root._ymouse};
              //pt = {x:142, y:182}; //I tried to set this based on the x and y of one of the locations but since the map is looking at the root it doesn't work this way
             
                }
            }
            onClipEvent (enterFrame) {
                if (!zoom) {
                    return;
                }
                _root._xscale += dir*i*30/20;
            //map._xscale += dir*i*30/20;//x of movie clip, tried to set the scale to the mc but didn't work
                _root._yscale += dir*i*25/20;
            //map._yscale += dir*i*25/20;//y of movie clip
                var pt2 = {x:pt.x, y:pt.y};
            //var pt2 = {x:141.9, y:177};
                _root.localToGlobal(pt2);
            //map.localToGlobal(pt2);
                _root._x -= (pt2.x-pt.x);
            //map._x -= (pt2.x-pt.x);
                _root._y -= (pt2.y-pt.y);
            //map._y -= (pt2.y-pt.y);
                i++;
                if (i == 12) {
                    zoom = false;
                    i = 0;
             
                }
            }

            • 3. Re: zooming to certain map locations
              robdillon Most Valuable Participant

              You don't say what version of Flash you are using but I made you an example using Flash 9 and AS2. It is much simpler than what you are working with now. It's also more adaptable. Let me know if you need more explanation.

              • 4. Re: zooming to certain map locations
                robdillon Most Valuable Participant

                Maybe the attachment will work this time...

                • 5. Re: zooming to certain map locations
                  MeadowRyan Level 1

                  there appears to be nothing in this zip file? thanks Rob

                  • 6. Re: zooming to certain map locations
                    robdillon Most Valuable Participant

                    When I download the zip file and unzip it, I get a file named zoomMap.fla.

                     

                    In any case, try this: http://www.ddg-designs.com/downloads/zoomMap.zip

                    • 7. Re: zooming to certain map locations
                      MeadowRyan Level 1

                      I think my question has been answered so basically you have your map as the main mc, then within that a container mc(does this need to cover all spots which will be zoomed in on?) and within that are all your spots? this is all using the tweening class?

                       

                      thanks Rob

                      • 8. Re: zooming to certain map locations
                        MeadowRyan Level 1

                        is this AS2?

                        • 9. Re: zooming to certain map locations
                          robdillon Most Valuable Participant

                          Yes, the movieClip on the stage contains the map clip and a movieClip that holds all of the hot spots, and yes it is AS2.

                          • 10. Re: zooming to certain map locations
                            MeadowRyan Level 1

                            Ok, I had something similar to this working courtesy of help from "Ned Murphy" but Im needing multiple points which I've recreated to what seems is exactly like the one you have with Europe where Im using the entire world map. I have my hot spots all in the us with theMap mc, then within that is the spots mc and main map mc, within the spots mc I have each individual spot, but when I zoom it still zooms to the center of my map mc and not to each individual hot spot mc...am I missing something? Do I need to create a mc within "theMap" mc on top of each point to show what to center to? thanks

                            • 11. Re: zooming to certain map locations
                              MeadowRyan Level 1

                              then only thing I don't have is each county broken down into their own object within the map mc

                              • 12. Re: zooming to certain map locations
                                robdillon Most Valuable Participant

                                Look at the actionscript that I wrote in frame 1. There is a line that starts: "var hotSpotList:Array = new Array(theMa..." This is a listing of all of the instance names of the hot spot movieClips. You will need to add in your hot spots to this array. Then the movie should work as you expect.

                                • 13. Re: zooming to certain map locations
                                  MeadowRyan Level 1

                                  that's exactly what I have except currently I have 5 spots, currently I have my main mc "theMap" within that is the "spots" mc which holds my spot1, 2, 3, etc. mc's also my map mc is within the "theMap"(does this need to be adjusted by the registration pt. at all?) within the "map" mc which is equivalent to your "europe" mc is just my original bitmap, I don't have anything broken down into countries.

                                  • 14. Re: zooming to certain map locations
                                    robdillon Most Valuable Participant

                                    Your map doesn't need to be broken up into countries. The code is just moving the overall movieClip "theMap". The two movieClips inside the map and the spots should be centered on the registration point. If you want, attach your movie and I'll take a look at it.

                                    • 15. Re: zooming to certain map locations
                                      MeadowRyan Level 1

                                      ok, everything is working, except when I try to upload the file to my webserver, nothing shows up does something else need to be loading to work with the tween class files?

                                      • 16. Re: zooming to certain map locations
                                        robdillon Most Valuable Participant

                                        What do you mean by "nothing shows up"? Do you see any part of the web site? You don't have to do anything special to have the tweens work from a server. Can you give us a URL to look at?

                                        • 17. Re: zooming to certain map locations
                                          MeadowRyan Level 1

                                          its there now, sorry for the confusion....thanks for the guidance Rob

                                          • 18. Re: zooming to certain map locations
                                            robdillon Most Valuable Participant

                                            It shows up and works correctly for me. Check your Flash plug-in to be sure that you have the correct one installed.

                                            • 19. Re: zooming to certain map locations
                                              MeadowRyan Level 1

                                              ok everything works perfectly and I have all my points...all 95 points(cities) loaded, how would I go about when clicking on one of the cities to load a movie or an informational box about that city, the problem is getting it to load only when zoomed in not while the map is at its normal location.

                                              • 20. Re: zooming to certain map locations
                                                robdillon Most Valuable Participant

                                                Look at the information on the Tween class. You can use the end of the tween to call a function. You can have this function show your supplimental information. You can then use the same function that zooms out to remove the information.

                                                • 21. Re: zooming to certain map locations
                                                  MeadowRyan Level 1

                                                  function zoomIn() {
                                                  tweenInSX = new Tween(theMap,"_xscale",Strong.easeOut,theMap._xscale,scaleMax,2,true);
                                                  tweenInSY = new Tween(theMap,"_yscale",Strong.easeOut,theMap._yscale,scaleMax,2,true, hotSpotList[s].onRollOver(trace("hello")));
                                                  tweenInX = new Tween(theMap, "_x", Strong.easeOut, theMap._x, (screenCenterX-(distanceMultiplier*this._x)), 2, true);
                                                  tweenInY = new Tween(theMap, "_y", Strong.easeOut, theMap._y, (screenCenterY-(distanceMultiplier*this._y)), 2, true);
                                                  }

                                                   

                                                  ok, so I believe if I call my function as above where when the function is zoomed in while I rollover one of my points, in this case it outputs hello....what I want it to do is read in information to an empty mc about the location Im currently rolled over...ex. Miami, Florida population, etc.

                                                   

                                                  Would this be easier to just do a rollover for each location or can I create a function to do this, but how to read in the information for each point?

                                                   

                                                  thanks

                                                  • 22. Re: zooming to certain map locations
                                                    MeadowRyan Level 1

                                                    ok, instead of doing what I just mentioned...what I'd like to do is I believe use the local connection function so that once I press one of the points it will display the appropriate data for that point in another swf next to it....does anyone have a good local connection example or give me some pointers how to start doing this with my map?

                                                     

                                                    thanks

                                                    • 23. Re: zooming to certain map locations
                                                      robdillon Most Valuable Participant

                                                      There are a lot of ways to do this. You don't want to use localconnection however. You could make a movieClip, or a separate movie that contains this supplimental information. Then you could load in the external .swf or position the internal movieClip on the stage and make it not visible. Then, when you zoom in, you can move this movieClip to a position on the stage where it can be read and then move it to a frame that shows the correct information. When you zoom out, make the clip invisible and move it out of visible stage area.

                                                      • 24. Re: zooming to certain map locations
                                                        MeadowRyan Level 1

                                                        The thing is I'm going to have information on about 90 spots....would using loadvars work better?

                                                        • 25. Re: zooming to certain map locations
                                                          MeadowRyan Level 1

                                                          http://www.chrobinson.com/ContactUs/FindABranchOffice/default.aspx

                                                           

                                                           

                                                          this is pretty  much what Im trying to when you click on one of the locations below it loads the contact info or whatever data is needing...why wouldn't I want to use a localconnection for this, or would it be easier to make the map and the data which is loading one big swf with the area for the data to be loaded an empty mc which changes loading info per which point clicked on.

                                                          • 26. Re: zooming to certain map locations
                                                            robdillon Most Valuable Participant

                                                            How much information are you going to show in each of these points? Does the information bubble need to float with the cursor like in the example? Is the information going to change at some point or is it going to remain the same?

                                                            • 27. Re: zooming to certain map locations
                                                              MeadowRyan Level 1

                                                              The info would remain the same, couldn't I just have everything all in one swf, put an empty mc to the right of my map in some white space where when each pt is clicked it loads the info into that mc?

                                                              • 28. Re: zooming to certain map locations
                                                                tripleA999 Level 1

                                                                The example you showed is a complex one

                                                                the example contains

                                                                2 different swf files and heavy xml file, and most of the options are controlling through XML file, and xml file contains around 1000 lines code

                                                                 

                                                                this is what i have checked

                                                                • 29. Re: zooming to certain map locations
                                                                  MeadowRyan Level 1

                                                                  basically all I'm trying to do is when each point is clicked information for that point will appear to the right, probably no more than 2 or 3 short lines, then as you click on different point it does the same....how would one go about doing the hovering thing when rolling over each point.

                                                                   

                                                                  thanks for all the help

                                                                  • 30. Re: zooming to certain map locations
                                                                    robdillon Most Valuable Participant

                                                                    If the content of each of these information bubble will remain the same then you don't need to be concerned about the ease of editing. If the volume of the content will be relatively small, then the download will be relatively small. This means that you could put all of the text into the movie and not be concerned about loading content or external movies, at least for this problem.

                                                                     

                                                                    At its very simplest, you would create a movieClip in the size and shape that you want to hold the text. Either create 90 or so duplicates to accomodate each bit of information or, create a dynamic textfield in this clip to hold the information and then write 90 variables to hold the text string for each bit of information.

                                                                     

                                                                    Hide the information bubble movieClip off the visible area of the stage, when the user rolls over a hot spot, zoom in, then at the end of the zoom, move the info bubble clip to the position of the cursor and set the text of the dynamic textfield to the proper variable's text, or, add in the appropriate info bubble movieClip to the stage and position it to the cursor.

                                                                    • 31. Re: zooming to certain map locations
                                                                      MeadowRyan Level 1

                                                                      Ok, I have a mc on the same level as all my points called "textholder" with a dynamic text field within in called the same instance name "textholder". On one of my point for my script I have

                                                                       

                                                                      on (rollOver) {

                                                                           textholder.text = "test";

                                                                      }

                                                                       

                                                                       

                                                                      Although when I click on the point, "spot53" nothing happens

                                                                       

                                                                       

                                                                      The other problem would be if this dynamic text field is stationary when I click on for instance a point on the opposite coast the text box will not be viewable, is there a way to move the text box according to the location of the point being clicked.

                                                                       

                                                                      This may be easier to do with what I was thinking by scaling down the map so that I have an area to the right of the map which is blank which stays stationary even when the map is zoomed in but holds the text for each point clicked.

                                                                      • 32. Re: zooming to certain map locations
                                                                        MeadowRyan Level 1

                                                                        ok, I thought I could just rescale the map to be half the size, then zoom in on the point and only have it zoom into my minimzed area...where originally the size of the main mc theMap was 900 x 400, I made it and all mc's within it, hot spots, world 450 x 300, but it zooms to the full size of the canvas. Is it possible to have it only zoom within the size of 450 x 300?

                                                                        • 33. Re: zooming to certain map locations
                                                                          MeadowRyan Level 1

                                                                          all right back to just doing the movie clips for each point, putting within the zoomIn() function I've made another tween variable tweenInText

                                                                           

                                                                          tweenInText = new Tween(spot53.onRollOver(textholder.text = "hello"),spot53.onRollOut(textholder.text = ''));

                                                                           

                                                                          which loads the text into my dynamic box, but it's happening whenever I click on any of the points, also is there a way to set the location of the dynamic text box?

                                                                          • 34. Re: zooming to certain map locations
                                                                            MeadowRyan Level 1

                                                                            is there any way you could show me a small example of this, I have my variables created within all the action script on frame 1, but to get the text to only show when its zoomed in do I put something like this:

                                                                             

                                                                            spot53.onRollOver(textholder.text = text1)

                                                                            spot53.onRollOut(textholder.text = ' ')

                                                                             

                                                                            ...then do that for every hot spot?

                                                                             

                                                                             

                                                                            I don't see how the text box will move around?

                                                                             

                                                                            thanks for all your help on this, I know this is probably really simple, but its not working.

                                                                             

                                                                            I have my mc, with my dynamic text box within it within the "hot spots" mc which is within the main mc...is that correct?

                                                                            • 35. Re: zooming to certain map locations
                                                                              MeadowRyan Level 1

                                                                              by creating a tween doing this?

                                                                              • 36. Re: zooming to certain map locations
                                                                                MeadowRyan Level 1

                                                                                are you meaning using LoadVars?

                                                                                • 38. Re: zooming to certain map locations
                                                                                  MeadowRyan Level 1

                                                                                  ok, now I see, so the variable is created text1, 2, etc. for each point you have then  you have the dynamic text box within the mc  then the bubble shows up by coming from off the stage then stopping only for those points  pressed....thanks so much for your help on this....my action script is rusty, it can get pretty frustrating but once I see it...I'm like oh that's how it works.