在前面几篇文章中简单玩耍了一下在线和离线加载高德地图图层;今天再次完善一下添加Mark图层和展示详细信息弹窗;来看看最终效果:
添加Mark无非就是用了PictureMarkerSymbol:
PictureMarkerSymbol picMarkSymbol = await GetPictureMarker();
MapPoint mapPoint = new MapPoint(footPrint.Coordinate.X, footPrint.Coordinate.Y, SpatialReferences.Wgs84);
Graphic graphic = new Graphic(mapPoint, picMarkSymbol);
graphic.Attributes["Name"] = footPrint.PositionName;
graphic.Attributes["DetailedInfor"] = footPrint.DetailedInfor;
graphic.Attributes["Longitude"] = mapPoint.X;
graphic.Attributes["Latitude"] = mapPoint.Y;
关于图片直接 通过内嵌资源方式获取:
Assembly currentAssembly = Assembly.GetExecutingAssembly();using(Stream resourceStream = currentAssembly.GetManifestResourceStream("MapControl.Images.FootPrint.png")){// Create new symbol using asynchronous factory method from streamPictureMarkerSymbol pinSymbol = await PictureMarkerSymbol.CreateAsync(resourceStream);pinSymbol.Width = 30;pinSymbol.Height = 30;pinSymbol.OffsetX = 15;pinSymbol.OffsetY = 15;return pinSymbol;
}
点击Mark展示详细信息:
CalloutDefinition myCalloutDefinition = new CalloutDefinition(name, detailInfor);
myCalloutDefinition.Icon = null;
myCalloutDefinition.LeaderOffsetX = 15;
myCalloutDefinition.LeaderOffsetY = 15;
// Display the callout
MySceneView.ShowCalloutForGeoElement(graphic, e.Position, myCalloutDefinition);
最终简单的效果先这样吧;以后有时间的话,可以再去摸索一下更复杂的效果;编程不息、Bug不止、无Bug、无生活;改bug的冷静、编码的激情、完成后的喜悦、挖坑的激动 、填坑的兴奋;这也许就是屌丝程序员的乐趣吧;今天就到这里吧;希望自己有动力一步一步坚持下去;生命不息,代码不止;大家抽空可以看看今天分享的效果,有好的意见和想法,可以在留言板随意留言;我看到后会第一时间回复大家,多谢大家的一直默默的关注和支持!如果觉得不错,那就伸出您的小手点个赞并关注一下,多谢您的支持!