android地图,怎么添加自定义InfoWindow

2024-11-14 11:20:17
推荐回答(1个)
回答1:

ArcGIS API for Flex本身提供了infowindow,但是用在项目中的话比较难看,不太美观。今天研究了一下infowindow组件的自定义,其梁灶世实是调用辩并API提供的组件只是美化了一下而已,先跟大家分享。哪儿有错橡肢可以直接批评我很乐意接受批评的,呵呵呵。好了废话不说了,直接放上代码:
InfoWindow.mxml

xmlns:esri="http://www.esri.com/2008/ags"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:samples="InfoWindowRenderer.*" >

@namespace esri "http://www.esri.com/2008/ags";
@namespace s "library://ns.adobe.com/flex/spark";
@namespace samples "InfoWindowRenderer.*";
.styles
{
fills:#81C3FB blue green;
border-color:green;
border-thickness: 1;
background-color: #81C3FB;
font-size: 14;
upper-left-radius: 15;
lower-right-radius:15;
info-placement: top;
}


import com.esri.ags.Graphic;
import com.esri.ags.events.GraphicEvent;
import com.esri.ags.geometry.MapPoint;
import com.esri.ags.geometry.Polyline;
private function graphicAddHandler(event:GraphicEvent):void
{
event.graphic.toolTip = "工程编号:"+event.graphic.attributes.Id+"\n"
+ "工程名:"+event.graphic.attributes.NAME ;
event.graphic.addEventListener(MouseEvent.CLICK, onMouseCLickHandler);
}
private function onMouseCLickHandler(event:MouseEvent):void
{
const graphic:Graphic = event.target as Graphic;
if (graphic)
{
const mapPoint:MapPoint = (Polyline(graphic.geometry)).paths[0][0] as MapPoint;
var infoContent:InfowindowContent = new InfowindowContent();
infoContent.data = graphic.attributes;
map.infoWindowContent = infoContent;
map.infoWindow.styleName = "styles";
const point:Point = map.toScreen(mapPoint);
map.infoWindow.label = graphic.attributes.NAME;
map.infoWindow.show(map.toMap(point));
}
}
]]>






graphicAdd="graphicAddHandler(event)"
mode="snapshot"
symbol="{sls}"
outFields="*"
url="http://localhost:8399/arcgis/rest/services/GEOSWNMap/MapServer/1">