开发者

Add a polygon as a marker in Google Maps Flash Api

I am creating a project in Flash using the Google Maps API and docs.

I'm trying to add a marker to the map, which is draggable but I don't want it to look like the standard Google Maps bubble开发者_StackOverflow中文版-style marker. Is it possible to have a custom polygon or image but still keep the draggability?


You can use something like this:

[Embed(source="assets/MyIcon.png")] private var myIcon:Class; //defines the marker icon to be used

. . .

// then in Your code.

var optObj:Object = new Object();
optObj.icon = new myIcon(); // instance of the myIcon Class
optObj.iconOffset = new Point(-11.5, -17.5); // this is optional, to set center of icon visually
optObj.draggable = true; // this option makes draggable Icon
var latlng = new LatLng(xxx, xxx); // replace xxx with your lat/lng values.
var marker:Marker = new Marker(latlng, new MarkerOptions(tmpObj));
map.addOverlay(marker); // adds the marker to your overlay

This is the way i do it, hope You find it usefull.

Regards.

Omar Guzmán.


I don't think you can use a Polygon as a Marker icon, although I have't tried it. The MarkerOptions class lets you specify a DisplayObject to be used instead of the default bubble marker...that's probably you're easiest solution.

One thing you could do if you wanted a more complex Marker is to create your own CustomMarker class which extends Marker. This way you can add extra functionality.

Lewis

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜