c# - How to add a UI element above Map Icon to show address in Windows 10? -


i working on mapcontrol in windows 10 , want display location address above map icon. know how add map icon not aware of adding ui element above it. added map icon using following code

mapcontrol map = frameworkelement mapcontrol; map.mapservicetoken= "my service token"; basicgeoposition councilposition = new basicgeoposition() {      latitude = convert.todouble(info.gettype().getruntimeproperty("latitude").getvalue(info, null)),      longitude = convert.todouble(info.gettype().getruntimeproperty("longitude").getvalue(info, null)) };  geopoint pinpoint = new geopoint(councilposition);  mapicon locationpin = new mapicon(); locationpin.image= randomaccessstreamreference.createfromuri(new uri("ms-appx:///images/pushpin.png")); locationpin.title = councilinfo.council_name; locationpin.collisionbehaviordesired = mapelementcollisionbehavior.remainvisible; locationpin.location = councilpoint; locationpin.normalizedanchorpoint = new point(0.5, 1.0); locationpin.zindex = 0;  map.mapelements.add(locationpin); await map.trysetviewasync(locationpin.location, 15d, 0, 0, mapanimationkind.bow); 

and want achieve same below screenshots

enter image description here

since programmatic adding mapicons hectic custom template. here's how using map control inside app

    <maps:mapcontrol x:name="mapcontrol"  mapservicetoken="yourtoken" >                     <maps:mapitemscontrol itemssource="{binding yourdata, mode=twoway}">                         <maps:mapitemscontrol.itemtemplate>                             <datatemplate>                                 <stackpanel tapped="mapicon_tapped" orientation="horizontal">                                     <image height="30" verticalalignment="top" maps:mapcontrol.location="{binding location}" maps:mapcontrol.normalizedanchorpoint="0.5,0.5" source="ms-appx:///images/pushpin.png"/>                                     <border borderthickness="1" borderbrush="lightgray" visibility="{binding detailsvisibility}">                                         <stackpanel x:name="mapicon"    background="white" >                                             <textblock  text="{binding yourmin}" foreground="black"  fontweight="semibold" fontsize="16" margin="5" textwrapping="wrapwholewords"  />                                             <textblock text="{binding yourcar}" foreground="gray"  fontweight="semibold" fontsize="12" margin="5" textwrapping="wrapwholewords"/>                                             <image source="your arrow"/>                                         </stackpanel>                                     </border>                                 </stackpanel>                             </datatemplate>                         </maps:mapitemscontrol.itemtemplate>                     </maps:mapitemscontrol>                 </maps:mapcontrol> 

now here need keep adding data yourdata add more pushpin. there 2 properties added
1. location- of geopoint type take care of position pushpin should placed based on latitude , longitude e.g temp.location = new geopoint(new basicgeoposition { latitude = double.parse(temp.lat), longitude = double.parse(temp.long) });
2. visibility- used handle pushpin detail visibility available on taping it. eg. temp.detailsvisibility = windows.ui.xaml.visibility.collapsed;
need add these values yourdata binding.


Comments

Popular posts from this blog

Ansible - ERROR! the field 'hosts' is required but was not set -

customize file_field button ruby on rails -

SoapUI on windows 10 - high DPI/4K scaling issue -