TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
chitrang shah
NA
6
5.3k
gps based vehicle tracking system for windows phone 7
Aug 7 2013 2:24 AM
HOW TO ADD TOLLTIP IN ABOVE CODE SO THAT INFORMATION CAN GET ON MOUSEOVER ON PIN?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
//using System.Windows.Controls;
using Microsoft.Phone.Controls;
using System.Device.Location;
using Microsoft.Phone.Controls.Maps;
using WindowsPhoneApplication1.GPSService;
using WindowsPhoneApplication1.Class;
using System.Xml;
using System.Xml.Linq;
//using WindowsPhoneApplication1.TerraService;
using System.Xml.Schema;
using System.Text;
using System.IO;
namespace WindowsPhoneApplication1
{
public partial class MainPage : PhoneApplicationPage
{
GPSService.ServiceSoapClient svc = new ServiceSoapClient();
// GetDashboardLocationData.ServiceSoapClient client = new GetDashboardLocationData.ServiceSoapClient();
GeoCoordinateWatcher myCoordinateWatcher;
double latitude, longitude;
public Pushpin pin;
Location l = new Location();
IList<Location> l1;
// Constructor
public MainPage()
{
InitializeComponent();
pin = null;
//client.ConvertLonLatPtToNearestPlaceCompleted += new EventHandler<TerraService.ConvertLonLatPtToNearestPlaceCompletedEventArgs>(client_ConvertLonLatPtToNearestPlaceCompleted);
//map1.ZoomBarVisibility = System.Windows.Visibility.Visible;
l1 = new List<Location>();
pp1=new List<Pushpin>();
// client.DownloadStringCompleted+=new DownloadStringCompletedEventHandler(client_DownloadStringCompleted);
SupportedOrientations = SupportedPageOrientation.Portrait | SupportedPageOrientation.Landscape;
pin = new Pushpin();
System.Windows.Threading.DispatcherTimer dispatcherTimer = new System.Windows.Threading.DispatcherTimer();
dispatcherTimer.Tick += new EventHandler(dispatcherTimer_Tick);
dispatcherTimer.Interval = new TimeSpan(0, 0, 10);
dispatcherTimer.Start();
}
IList<Pushpin> pp1;
private void dispatcherTimer_Tick(object sender, EventArgs e)
{
svc.getDashboardLocationDataAsync(51);
// svc.getLocationDataAsync(51);
if (cmbVehicle.Items.Count() == 0)
{
//cmbVehicle.Items.Add(l1);
for (int i = 0; i < l1.Count(); i++)
{
cmbVehicle.Items.Add(l1[i].vehicleid);
}
}
ToolTipService.SetToolTip(pin, l.vehicleid);
// svc.getLocationDataForDetailsAsync("51");
map1.Children.Remove(pin);
pin.Location = new System.Device.Location.GeoCoordinate(l.latitude,l.longitude);
pin.Content = new Rectangle()
{
Fill = image,
StrokeThickness = 5,
Height = 40,
Width = 30,
};
ToolTipService.SetToolTip(pin, l.vehicleid);
map1.Children.Add(pin);
map1.Center = new GeoCoordinate(l.latitude, l.longitude);
}
//{
// svc.getDashboardLocationDataAsync(51);
// for (int i = 0; i < pp1.Count; i++)
// {
// map1.Children.Remove(pp1[i]);
// }
// for (int i = 0; i < l1.Count; i++)
// {
// Pushpin pin1 = new Pushpin();
// pin1.Location = new System.Device.Location.GeoCoordinate(l1[i].latitude, l1[i].longitude);
// pin1.Content = new Rectangle()
// {
// Fill = image,
// StrokeThickness = 5,
// Height = 40,
// Width = 30,
// };
// pp1.Add(pin1);
// map1.Center = new GeoCoordinate(l1[i].latitude, l1[i].longitude);
// }
// for (int i = 0; i < pp1.Count(); i++)
// {
// map1.Children.Add(pp1[i]);
// }
private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e)
{
//l.latitude = 22.187405;
//l.longitude = 72.861328;
//map1.Center = new GeoCoordinate(l.latitude, l.longitude);
map1.ZoomLevel = 5;
map1.ZoomBarVisibility = Visibility.Visible;
myCoordinateWatcher = new GeoCoordinateWatcher(GeoPositionAccuracy.High);
myCoordinateWatcher.PositionChanged += new
EventHandler<GeoPositionChangedEventArgs<GeoCoordinate>>(myCoordinateWatcher_PositionChanged);
// svc.getLocationDataForDetailsAsync("vehicleid");
svc.getLocationDataForDetailsCompleted += new EventHandler
<GPSService.getLocationDataForDetailsCompletedEventArgs>(svc_getDataCompleted);
svc.getDashboardLocationDataAsync(51);
svc.getDashboardLocationDataCompleted += new EventHandler<getDashboardLocationDataCompletedEventArgs>(svc_getDashboardLocationDataCompleted);
//svc.getLocationDataForDetailsCompleted += new EventHandler<GPSService.getLocationDataForDetailsCompletedEventArgs>(svc_getDataCompleted);
}
//private void svc_getDataCompleted(object sender, GPSService.getLocationDataForDetailsCompletedEventArgs e)
//{
// string xml = e.Result;
// var test = XElement.Parse(xml)
// .Descendants("map")
// .First().Descendants("longitude").First()
// .Value;
// l.longitude = Convert.ToDouble(test);
// test = XElement.Parse(xml)
// .Descendants("map")
// .First().Descendants("latitude").First()
// .Value;
// l.latitude = Convert.ToDouble(test);
//}
private void svc_getDashboardLocationDataCompleted(object sender, GPSService.getDashboardLocationDataCompletedEventArgs e)
{
string xml = e.Result;
l1.Clear();
var maps = XElement.Parse(xml)
.Descendants("map");
foreach (XElement x in maps)
{
Location ln = new Location();
var test = x.Descendants("longitude").First()
.Value;
ln.longitude = Convert.ToDouble(test);
test = x.Descendants("latitude").First()
.Value;
ln.latitude = Convert.ToDouble(test);
test = x.Descendants("vehicle_no").First().Value;
ln.vehicleid = test;
//cmbVehicle.Items.Add(ln.vehicleid);
l1.Add(ln);
// cmbVehicle.Items.Add(l1);
}
}
//var list = from ele in XDocument.Parse(@"C:\Users\chitrang\Documents\Visual Studio 2010\Projects\WindowsPhoneApplication1\WindowsPhoneApplication1\xml file\vehicle.xml").Descendants("map")
// select new
// {
// Vehicle = (string)ele.Element("vehicle_no")
// };
//foreach (var t in list)
//{
// ComboBox1.Items.Add(t);
//}
//private void svc_getDataCompleted(object sender, GPSService.getLocationDataForDetailsCompletedEventArgs e)
//{
// string xml = e.Result;
// var test = XElement.Parse(xml)
// .Descendants("map")
// .First().Descendants("longitude").First()
// .Value;
// l.longitude = Convert.ToDouble(test);
// test = XElement.Parse(xml)
// .Descendants("map")
// .First().Descendants("latitude").First()
// .Value;
// l.latitude = Convert.ToDouble(test);
// test = XElement.Parse(xml)
// .Descendants("map")
// .First().Descendants("vehicle_no").First()
// .Value;
// l.vehicleid = test;
//}
void myCoordinateWatcher_PositionChanged(object sender, GeoPositionChangedEventArgs<GeoCoordinate> e)
{
if (!e.Position.Location.IsUnknown)
{
l.latitude = e.Position.Location.Latitude;
l.longitude = e.Position.Location.Longitude;
map1.Center = new GeoCoordinate(l.latitude, l.longitude);
map1.SetView(new GeoCoordinate(l.latitude, l.longitude), map1.ZoomLevel);
myCoordinateWatcher = new GeoCoordinateWatcher(GeoPositionAccuracy.High);
myCoordinateWatcher.PositionChanged += new EventHandler<GeoPositionChangedEventArgs<GeoCoordinate>>(myCoordinateWatcher_PositionChanged);
// svc.getDashboardLocationDataAsync(51);//"GJ12Y8277(T-07)");et
//svc.getDashboardLocationDataCompleted += new EventHandler<getDashboardLocationDataCompletedEventArgs>(svc_getDataCompleted1);
map1.Center = new GeoCoordinate(l.latitude, l.longitude);
map1.Children.Add(pin);
}
}
private void button2_Click(object sender, RoutedEventArgs e)
{
map1.Children.Remove(pin);
pin = null;
}
ImageBrush image = new ImageBrush()
{
ImageSource = new System.Windows.Media.Imaging.BitmapImage
(new Uri("http://www.iconshock.com/img_jpg/SOPHISTIQUE/communications/jpg/128/car_icon.jpg"))
};
private void button1_Click(object sender, RoutedEventArgs e)
{
map1.Mode = new RoadMode();
}
public int i { get; set; }
private void cmbVehicle_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (cmbVehicle.Items.Count > 0)
{
// svc.getLocationDataForDetailsCompleted += new EventHandler<getLocationDataForDetailsCompletedEventArgs>(svc_getLocationDataForDetailsCompleted);
svc.getLocationDataForDetailsAsync(cmbVehicle.SelectedItem.ToString());
}
}
private void svc_getDataCompleted(object sender, GPSService.getLocationDataForDetailsCompletedEventArgs e)
{
string xml = e.Result;
var test = XElement.Parse(xml)
.Descendants("map")
.First().Descendants("longitude").First()
.Value;
l.longitude = Convert.ToDouble(test);
test = XElement.Parse(xml)
.Descendants("map")
.First().Descendants("latitude").First()
.Value;
l.latitude = Convert.ToDouble(test);
test = XElement.Parse(xml)
.Descendants("map")
.First().Descendants("vehicle_no").First()
.Value;
l.vehicleid = test;
}
}
}
Reply
Answers (
1
)
GRID EDIT IN 2 TIER
07-2013(how to make query creating