we need functionality allow touch on mappin. , on touch, draw route between current location , touchpin. touch pins coming xml file , binding map control.
following code.
i getting error
error: bindingexpression path error: 'latitude' property not found on 'mappin, version=1.0.0.0, culture=neutral, publickeytoken=null'. bindingexpression: path='latitude' dataitem='mappin, version=1.0.0.0, culture=neutral, publickeytoken=null'; target element 'windows.ui.xaml.controls.textblock' (name='txtlatitude'); target property 'text' (type 'string')
xaml:
<map:mapcontrol x:name="map1" landmarksvisible="true" loaded="map1_loaded"> <map:mapitemscontrol x:name="mapitems" > <map:mapitemscontrol.itemtemplate> <datatemplate> <stackpanel x:name="stckpin" horizontalalignment="left" height="100" verticalalignment="top" width="100" tapped="stckpin_tapped"> <image x:name="imgpin" source="ms-appx:///assets/icon.png" map:mapcontrol.location="{binding location}" opacity="0.8" map:mapcontrol.normalizedanchorpoint="{binding nap}" height="50" width="50" /> <textblock x:name="txtlatitude" textwrapping="wrap" text="{binding latitude, updatesourcetrigger=propertychanged, converter={staticresource doubleconverter1}}" /> </stackpanel> </datatemplate> </map:mapitemscontrol.itemtemplate> </map:mapitemscontrol> </map:mapcontrol>
c#:
namespace maplocatornamespace { public sealed partial class maplocator : page { private void stckpin_tapped(object sender, tappedroutedeventargs e) { stackpanel stkpin = (stackpanel)sender; double lolatitude = convert.todouble(((textblock)stkpin.children[1]).text); } } public class doubleconverter : ivalueconverter { public object convert(object value, type targettype, object parameter, string language) { var doublenumber = (double)value; return doublenumber.tostring("0.00#################"); } public object convertback(object value, type targettype, object parameter, string language) { throw new notimplementedexception(); } } }
how can bind latitude textblock , @ codebehind ?
i have solved myself,
what have done is, have add int column index may mapitem class, , added in 'tag' attribute of image. on tap event tag , index can search in list , and tapped pin.
now having pin whole detail, , current location , pin location can draw route.
thank you.