Advanced Flash Components
Search!
Search!
Home >  Knowledge Base >  G Map >  Questions about Interacting with...
Questions about Interacting with Polygons
Date: Sep 7, 2007   Views: 2663  
Question:
I've just downloaded your GMap component and, so far, it looks neat.

I am having trouble figuring out which parts of Google Map's API are exposed, which are re-implemented by you in Flash, and which are unavailable in your component. I was wondering if you could shed some light on this.

I need to create a map with polygon regions where the user can interact and select one or more regions. I'd use good ol' Google Maps but I've found javascript to be a bit sluggish with vector stuff. Here's what I can't figure out (so far)...

1.) I need to limit the zoom levels and pan range of the map. I realize that I can probably do this using MAP_POSITION_CHANGED and MAP_ZOOM_CHANGED but wondered whether there were any built in functionality for this.

2.) Tied to question #1, if I have to write my own zoom/pan limiting functions, it'd be nice to be able to only show the +/- zoom controls and not the whole slider (since I hate to show zoom options that the user won't be allowed to access -- bad interface design). Is there a GSmallZoomControl equivalent?

3.) Finally -- and here's were it gets interesting -- I need to create a bunch of GPolygons that interact with the mouse (so I need them to respond to mouseover, mouseout, and click events) and I need them to change color/opacity to provide feedback. Ok, so this is two questions:

3a.) I assume the polygons are all flash objects, what kind? Are they basic shapes or is there some way to create them a a button or mc -- I'd love to just say:
var myPolygon = map.addPolygon({points:shapeArray});
myPolygon.onRollOver = blah blah blah.

But, as it stands, I think that I only get to work with MAP_ON_ROLL_OVER and have to write my own isOverPolygon function (yuck). Am I wrong here? Is there a nice, easy, built-into-Flash approach here?

3b.) Once I detect a mouseOver or click event, I need to change the color of the polygon. From your examples, I see that your polygons have a "name:" property. How do I set the stroke's and fill's color/weight/opacity? More importantly, how do I change it dynamically?

Again, I know how to change these properties using Flash's setRGB and _alpha properties for button or mc instances -- but I don't know what types of objects I'm dealing with here.
Answer:

dvs_code (Admin)
Thank you for choosing our component!

The questions you're asking are not new. They have been already discussed on the forums and in the tutorials. Moreover we have a complete API documentation available for you to download from the component's page. Anyway, to save time for you, I will answer all your questions and give examples.

1. You're correct to use MAP_POSITION_CHANGED and MAP_ZOOM_CHANGED events. In this thread I give a good example of bounds and zoom limitation: Map bounds and zoom limitation. Look for the word 'Hawaii'.

2. You can add the zoom control in compact state.

map.addControl(map.GZoomControl({display:"compact"}));


3. You can and should use GEOMETRY_ON_RELEASE, GEOMETRY_ON_ROLL_OUT, GEOMETRY_ON_ROLL_OVER events of the geometry object. You can also chage the appearence of the geometry objects by modifing it's style properties. The complete list of properties is available in API documentation, which can be found here: API documentation. By the way, there is a nice tutorial, written by Andrei which covers the problems you're encountering: GPolygon explained

I hope this information will be useful. Please feel free to ask for further assistance. You're always welcome to the GMap Forum.

Dmitry.
Component Info