Click here to Skip to main content
15,896,063 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Hi everyone,

I am newbie on Winphone 7.

I am trying to get location of a smartphone and changes its when Emulator cahnges too.
But I don't know why it did not work.
Why???
Plz someone know about this.
Plz give me an Advice.
Thx in advance.
Sr for my bad English.
Sincerely.
my Project:http://www.mediafire.com/?bhr26qrki0u2obr

My GPSemulator :http://msdn.microsoft.com/en-us/gg616016
P/S: I am not trying to get Some1 progrmming for me.PLZ help me T_T.

<pre lang="c#">
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 Microsoft.Phone.Controls;
using Microsoft.Phone.Controls.Maps;

using System.Device.Location;



namespace PhoneApp1
{
    public partial class MainPage : PhoneApplicationPage
    {
        // Constructor
      

        GeoCoordinateWatcher watcher;
      

 
      
        Pushpin Pin = new Pushpin();
        String bingkey = "Ak3PcwHFqpbSJIES_QnB4Nqs6GMfcjDSkAsl-dgsDzui3UwWs6-lU5Gi1KqYxhu7";
 
        public MainPage()
        {

            InitializeComponent();

           
            MAP.CredentialsProvider = new ApplicationIdCredentialsProvider(bingkey);

            MAP.LogoVisibility = Visibility.Collapsed;
            MAP.CopyrightVisibility = Visibility.Collapsed;
            MAP.Mode = new AerialMode();
            MAP.Visibility = Visibility.Visible;


            this.watcher = new GeoCoordinateWatcher();
            this.watcher.PositionChanged += new EventHandler<geopositionchangedeventargs><geocoordinate>>(watcher_PositionChanged);
            bool started = this.watcher.TryStart(false, TimeSpan.FromMilliseconds(2000));
            if (!started)
            {
                txtStatus.Text=("GeoCoordinateWatcher timed out on start.");
            }


            Pin.Location = watcher.Position.Location;
            MAP.Center = Pin.Location;
            
          

          
          
            Ellipse Elip = new Ellipse();  
            SolidColorBrush mySolidColorBrush = new SolidColorBrush();        
            // Describes the brush's color using RGB values. // Each value has a range of 0-255.
             mySolidColorBrush.Color = Colors.Red; Elip.Width=20; Elip.Height = 20;
            Elip.Name = "locator"; Elip.Fill = mySolidColorBrush; Pin.Content = Elip;
            txtStatus.Text = String.Format("Acc Horz = {0:0.00} | Acc Vert = {1:0.00}",
            Pin.Location.HorizontalAccuracy, Pin.Location.VerticalAccuracy);
            MAP.Children.Add(Pin);

        }

        double curLatitude, curLongitude;


        void watcher_PositionChanged(object sender, GeoPositionChangedEventArgs<geocoordinate> e)
        {
            
            curLatitude=e.Position.Location.Latitude;
            curLongitude = e.Position.Location.Longitude;
            PrintPosition(curLatitude,curLongitude );
            Pin.Location = e.Position.Location;
            MAP.Children.Remove(Pin);
            MAP.Center = Pin.Location;
            MAP.Children.Add(Pin);
        }

      


        void PrintPosition(double Latitude, double Longitude)
        {
           txtStatus.Text=("Latitude: "+Latitude+ "Longitude "+ Longitude);
        }

      
        private void button1_Click(object sender, RoutedEventArgs e)
        {
            MAP.Mode = new RoadMode();

        }

        private void button2_Click(object sender, RoutedEventArgs e)
        {
            MAP.Mode = new AerialMode();

        }

        private void button3_Click(object sender, RoutedEventArgs e)
        {
            double zoom;
            zoom = MAP.ZoomLevel;
            MAP.ZoomLevel = ++zoom;

        }

        private void button4_Click(object sender, RoutedEventArgs e)
        {
            double zoom;
            zoom = MAP.ZoomLevel;
            MAP.ZoomLevel = --zoom;

        }


       
   
       

        private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e)
        {

        }

       

    

       
    }

  



}</geocoordinate></geocoordinate></geopositionchangedeventargs>
Posted
Updated 22-Nov-11 23:10pm
v3
Comments
RaisKazi 23-Nov-11 5:13am    
Edited: You missed to click on check box - "Treat my content as plain text, not as HTML", just below your Question Box. But you can correct your spellings by your own.

Your English is not too bad. You just don't have elementary respect to your readers. Your "Plz", "Thx" and "Sr" is not because you don't know correct spelling, but just because you are rude. I don't even mention nice formatting of your code.

But think about it: who is the looser? If you really need help — you are.

Who will be interested to spend time helping you looking at your sloppiness? People want to help only those who can be expected to really use the help.

—SA
 
Share this answer
 
Itz bit difficult to understand your question. In a nutshell, emulator is the simulation of phone devices. If it doesn't work in emulator, then it won't work at phone. So, review the code before deploying at phone.
 
Share this answer
 
--SAKryukov258K
SAID: "Your English is not too bad. You just don't have elementary respect to your readers. Your "Plz", "Thx" and "Sr" is not because you don't know correct spelling, but just because you are rude. I don't even mention nice formatting of your code.

But think about it: who is the looser? If you really need help — you are.

Who will be interested to spend time helping you looking at your sloppiness? People want to help only those who can be expected to really use the help."

Excuse me, how to formatting the code??? I used tool "Code" when copy code but It doesn't work. Same to link.??? It's not that i don't have respect.
But what will u do when u are confuse??? And don't how to say it???

I don't mean to be rude at all.
Sorry about "Sr" , "Thx".Because i thought that is internet english Langguage.
Thank for reading.
and thank GanesanSenthilvel. Maybe you are right. And i need to gather more infomation.
In the end, Thank for all of you and reading.
Please take care of me to the end.
Thank alot.
Sincerely.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900