How to draw a line between two Markers ?
How can I draw a line between two Markers ?
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?Hi Benoit,
There are PolylineClip and Polyline classes in the com.modestmaps.overlays package - you could try those?
var polylineClip:PolylineClip = new PolylineClip(map);
map.addChild(polylineClip);
var locations:Array = [ new Location(10,10), new Location (20,20) ];
var polyline:Polyline = new Polyline('poly-id-1', locations);
polylineClip.addPolyline(polyline);
You can also use a PolygonMarker and PolygonClip, and set the polygon marker to not autoclose and not fill.
var polygonClip:PolygonClip = new PolygonClip(map);
map.addChild(polygonClip);
var locations:Array = [ new Location(10,10), new Location (20,20) ];
var polygon:PolygonMarker = new PolygonMarker(map, locations, false);
polygon.fill = false;
polygon.redraw();
polygonClip.attachMarker(polygon, polygon.location);
If you just have one or two lines you can make your own simple overlay like this:
var overlay:Sprite = new Sprite();
map.addChild(overlay);
var loc1:Location = new Location(...); // *** set lat,lon here! ***
var loc2:Location = new Location(...); // *** and here! ***
var onMapChange:Function = function(event:MapEvent):void {
var pt1:Point = map.locationPoint(loc1);
var pt2:Point = map.locationPoint(loc2);
overlay.graphics.clear();
overlay.graphics.lineStyle(2, 0xffffff);
overlay.graphics.moveTo(pt1.x, pt1.y);
overlay.graphics.lineTo(pt2.x, pt2.y);
};
map.addEventListener(MapEvent.PANNED, onMapChange);
map.addEventListener(MapEvent.ZOOMED_BY, onMapChange);
map.addEventListener(MapEvent.EXTENT_CHANGED, onMapChange);
Loading Profile...



EMPLOYEE