我使用Google Maps API和文檔在Flash中創建項目。在Google Maps Flash Api中添加多邊形作爲標記
我想向地圖添加一個標記,這是可拖動的,但我不希望它看起來像標準的Google Maps氣泡樣式標記。是否可以有一個自定義的多邊形或圖像,但仍然保持可拖動性?
我使用Google Maps API和文檔在Flash中創建項目。在Google Maps Flash Api中添加多邊形作爲標記
我想向地圖添加一個標記,這是可拖動的,但我不希望它看起來像標準的Google Maps氣泡樣式標記。是否可以有一個自定義的多邊形或圖像,但仍然保持可拖動性?
您可以使用這樣的事情:
[Embed(source="assets/MyIcon.png")] private var myIcon:Class; //defines the marker icon to be used
。 。 。
//然後在你的代碼中。
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
這是我做的方式,希望你覺得它有用。
問候。
奧馬爾古茲曼。
我不認爲你可以使用多邊形作爲標記圖標,雖然我沒有嘗試過。 MarkerOptions類讓你指定一個DisplayObject來代替默認的氣泡標記......這可能是你最簡單的解決方案。
如果你想要一個更復雜的Marker,你可以做的一件事就是創建你自己的擴展Marker的CustomMarker類。這樣你可以添加額外的功能。
劉易斯