Phone 7 Bing map control - Add a pushpin when tap -
i using latest phone 7 rtm tools ( downloaded today, october 7 2010).
i trying simple thing here:
when user taps once on map control, want put pushpin there. also, want keep regular built-in behavior of map control ( tap twice zoom).
(if it's not possible keep both behaviors , maybe long press on map put pushpin).
when trying figuring out, came across documentation of changes made control map phone7: http://msdn.microsoft.com/en-us/library/ff955762.aspx
then saw new class mapinputeventargs, has viewportpoint member.
when looking @ code examples on regular silverlight map control saw this:
private void onmouseclick(object sender, mapmouseeventargs e) { point clicklocation = e.viewportpoint; location location = x_map.viewportpointtolocation(clicklocation); pushpin pushpin = new pushpin(); m_pushpinlayer.addchild(pushpin, new location(latitude, longitude)); }
but in phone7 case, can't find appropriate event handler, , not find uses mapinputeventargs in map control. searching on google gets me 1 result !!
so , appropriate event "tap once", , how can viewportpoint after event has been fired ?
thanks in advance.
just figured out if still having problems.
the mouseleftbuttonup , mouseleftbuttondown events have getposition method return point looking for
private void mapmain_mouseleftbuttonup(object sender, mousebuttoneventargs e) { point p = e.getposition(this.mapmain); geocoordinate geo = new geocoordinate(); geo = mapmain.viewportpointtolocation(p); mapmain.zoomlevel = 17; mapmain.center = geo; //---create new pushpin--- pushpin pin = new pushpin(); //---set location pushpin--- pin.location = geo; //---add pushpin map--- mapmain.children.add(pin); }
Comments
Post a Comment