zoom out
I have a map with markers placed on there but when I zoom out, they get bigger. When I zoom in, they get smaller. Is this a bug or do I have to code in something on my end?
1
person has this question
I have this question, too!
Tell me when someone answers.
The more people who ask this question, the more it gets noticed.
The more people who ask this question, the more it gets noticed.
Create a customer community for your own organization
Plans starting at $19/month
-
Inappropriate?How are your markers defined and added to the map?
Are you using the map's built in MarkerClip or something else? -
Inappropriate?Here's my code:
Just using putMarker(); and calling the built in sampleMarker and that SampleMarker.as for different colors but didnt change the code.
function placeMarkers(xmlNav:XMLList):void {
for each (var child:XML in xmlNav) {
var marker:SampleMarker = new SampleMarker();
var orangemarker:OrangeFlag = new OrangeFlag();
...
var _type = child.@type;
marker.title=child.caption.@name;
orangemarker.title=child.caption.@name;
..
customIcons = { "Ojibwa" :marker, "Dakota" :orangemarker,"Potawatomi":yellowmarker ,"Ottawa":greenmarker,"Menominee":bluemarker, "HoChunk":indigomarker, "Oneida":purplemarker, "Stockbridge":blackmarker};
_myGroup[_type].push(customIcons[_type]);
...
var loc:Location = new Location (child.caption.@lat, child.caption.@lng);
map.putMarker( loc,customIcons[_type]);
...
}
} -
Inappropriate?Can you post a demo somewhere? I can't figure out why this would cause the markers to scale.
Are you using stage.scaleMode? -
Inappropriate?http://clients.xenomedia.com/Indianso...
I would love to just show you my entire source code but I don't want to bother you too much.
I'm using the sample AS3 file and in there was stage.scaleMode = StageScaleMode.NO_SCALE; -
Inappropriate?I see. The markers are a fixed pixel size no matter what the scale of the map is. This is the intended behaviour for point markers in MarkerClip.
If you want markers to scale according to a geographical extent, use PolygonMarkers and add them to a PolygonClip (not the default MarkerClip).
If you want icons that scale according to the zoom level, you can also continue to use the default MarkerClip (used in map.putMarker) but also listen for EXTENT_CHANGED and ZOOMED_BY events and set the size of each marker accordingly... If you've drawn geographic shapes as markers you can set the scaleX and scaleY of the marker to be Math.pow(2, map.getZoom()-drawnZoom) where drawnZoom is the zoom at which the markers should have scale=1.
In any case, your map looks great to me - almost there!
1 person says
this answers the question
-
Inappropriate?ooo thanks alot!
-
Inappropriate?okay i've made some progress.
http://clients.xenomedia.com/Indianso...
I can get them smaller but when I zoom back in, they remain small....
I'm going to cry T^T
Question: what is onExtentChanged event? how does that differ from onZoomedBy?
map.getZoom(); did not work for me. It kept returning the same value (3)
so I used map.grid.zoomLevel ...maybe cause I'm using Tweenmap...
Also I didn't know what to do with the marker scale (drawnZoom). I dont think I'm good in math..
Any ideas to remedy this zoom back in problem?
here's my code: (not showing up right here...)
function onZoomedBy(event:MapEvent):void{
var _zoomLevel = Math.ceil(map.grid.zoomLevel);
var drawnZoom = map.getZoom()+2;
(for loop is not showing up on this comment)
var _bounds = _array["Ojibwa"][j];
_bounds.scaleX=Math.pow(2, _zoomLevel-drawnZoom);
_bounds.scaleY=Math.pow(2, _zoomLevel-drawnZoom);
}
}
-
Inappropriate?Yep, map.grid.zoomLevel is the accurate value, map.getZoom() is the integer value. That looks right.
However, your value for drawnZoom shouldn't change in onZoomedBy (it's nothing to do with map.getZoom - right?). It should be the zoom level at which your markers were originally drawn (the zoomlevel at which scaleX and scaleY are 1). It should remain constant for the duration of your application, unless you redraw your markers (but I don't think you do).
Try defining drawnZoom outside of your event handling code - just initialize it once at the beginning of your application. (I may have misunderstood but I think you're drawing the boundaries by hand in the Flash application - is that right? If you have coordinates for the boundaries let me know, I can help you use PolygonMarkers instead, they can scale themselves.)
The EXTENT_CHANGED event is dispatched when you call map.setExtent (or TweenMap's extent tweening functions). ZOOMED_BY and PANNED might not be called in that case (I'm pretty sure they're not but it's been a while since I checked). -
Inappropriate?thanks.
ok so just initialize the drawnZoom once. I'll try that.
I was considering polygon markers, but the boundaries have to be exactly like that. some have curves, some are groups of circles...
With the polygon markers, I have to get the map locations for each point... I think it'll be easier if I just draw it out in flash movieclips.
What do you think? -
Inappropriate?If drawing them out works for you, then go for it! The approach we're talking about here will work eventually... I think we're pretty close :)
Loading Profile...



EMPLOYEE