Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#
I need to create a desktop application in C # to get the geolocation
found one, only works on windows 7 because the plugin to gets location is not available for windows xp.
 
I found a function in html 5 geolocation, only do not know how to put it within the c #. It is not 100% but I have windows xp.
or if anyone knows another way to get geolocation windows XP.
could someone help me?
 

I found this code in html 5
index.html
 
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset=utf-8>
<meta name="viewport" content="width=620">
<title>HTML5 Demo: geolocation</title>
<link rel="stylesheet" href="css/html5demos.css">
<script src="js/h5utils.js"></script></head>
<body>
<section id="wrapper">
<div id="carbonads-container"><div class="carbonad"><div id="azcarbon"></div><script type="text/javascript">var z = document.createElement("script"); z.type = "text/javascript"; z.async = true; z.src = "http://engine.carbonads.com/z/14060/azcarbon_2_1_0_VERT"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(z, s);</script></div></div>
    <header>
      <h1>geolocation</h1>
    </header>
<meta name="viewport" content="width=620" />
 
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
    <article>
      <p>Finding your location: <span id="status">checking...</span></p>
    </article>
<script>
function success(position) {
  var s = document.querySelector('#status');
 
  if (s.className == 'success') {
    // not sure why we're hitting this twice in FF, I think it's to do with a cached result coming back
    return;
  }
 
  s.innerHTML = "found you!";
  s.className = 'success';
 
  var mapcanvas = document.createElement('div');
  mapcanvas.id = 'mapcanvas';
  mapcanvas.style.height = '400px';
  mapcanvas.style.width = '560px';
 
  document.querySelector('article').appendChild(mapcanvas);
 
  var latlng = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);
  var myOptions = {
    zoom: 15,
    center: latlng,
    mapTypeControl: false,
    navigationControlOptions: {style: google.maps.NavigationControlStyle.SMALL},
    mapTypeId: google.maps.MapTypeId.ROADMAP
  };
  var map = new google.maps.Map(document.getElementById("mapcanvas"), myOptions);
 
  var marker = new google.maps.Marker({
      position: latlng,
      map: map,
      title:"You are here! (at least within a "+position.coords.accuracy+" meter radius)"
  });
}
 
function error(msg) {
  var s = document.querySelector('#status');
  s.innerHTML = typeof msg == 'string' ? msg : "failed";
  s.className = 'fail';
 
  // console.log(arguments);
}
 
if (navigator.geolocation) {
  navigator.geolocation.getCurrentPosition(success, error);
} else {
  error('not supported');
}
 
</script><a id="html5badge" href="http://www.w3.org/html/logo/">
<img src="http://www.w3.org/html/logo/badge/html5-badge-h-connectivity-device-graphics-multimedia-performance-semantics-storage.png" width="325" height="64" alt="HTML5 Powered with Connectivity / Realtime, Device Access, Graphics, 3D & Effects, Multimedia, Performance & Integration, Semantics, and Offline & Storage" title="HTML5 Powered with Connectivity / Realtime, Device Access, Graphics, 3D & Effects, Multimedia, Performance & Integration, Semantics, and Offline & Storage">
</a>
    <footer><a href="/">HTML5 demos</a>/<a id="built" href="http://twitter.com/rem">@rem built this</a>/<a href="#view-source">view source</a></footer>
</section>
<a href="http://github.com/remy/html5demos"><img style="position: absolute; top: 0; left: 0; border: 0;" src="http://s3.amazonaws.com/github/ribbons/forkme_left_darkblue_121621.png" alt="Fork me on GitHub" /></a>
<script src="js/prettify.packed.js"></script>
<script>
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script>
try {
var pageTracker = _gat._getTracker("UA-1656750-18");
pageTracker._trackPageview();
} catch(err) {}</script>
</body>
</html>
 

and
h5utils.js
 
// For discussion and comments, see: http://remysharp.com/2009/01/07/html5-enabling-script/
/*@cc_on'abbr article aside audio canvas details figcaption figure footer header hgroup mark menu meter nav output progress section summary time video'.replace(/\w+/g,function(n){document.createElement(n)})@*/
 
var addEvent = (function () {
  if (document.addEventListener) {
    return function (el, type, fn) {
      if (el && el.nodeName || el === window) {
        el.addEventListener(type, fn, false);
      } else if (el && el.length) {
        for (var i = 0; i < el.length; i++) {
          addEvent(el[i], type, fn);
        }
      }
    };
  } else {
    return function (el, type, fn) {
      if (el && el.nodeName || el === window) {
        el.attachEvent('on' + type, function () { return fn.call(el, window.event); });
      } else if (el && el.length) {
        for (var i = 0; i < el.length; i++) {
          addEvent(el[i], type, fn);
        }
      }
    };
  }
})();
 
(function () {
 
var pre = document.createElement('pre');
pre.id = "view-source"
 
// private scope to avoid conflicts with demos
addEvent(window, 'click', function (event) {
  if (event.target.hash == '#view-source') {
    // event.preventDefault();
    if (!document.getElementById('view-source')) {
      // pre.innerHTML = ('<!DOCTYPE html>\n<html>\n' + document.documentElement.innerHTML + '\n</html>').replace(/[<>]/g, function (m) { return {'<':'&lt;','>':'&gt;'}[m]});
      var xhr = new XMLHttpRequest();
 
      // original source - rather than rendered source
      xhr.onreadystatechange = function () {
        if (this.readyState == 4 && this.status == 200) {
          pre.innerHTML = this.responseText.replace(/[<>]/g, function (m) { return {'<':'&lt;','>':'&gt;'}[m]});
          prettyPrint();
        }
      };
 
      document.body.appendChild(pre);
      // really need to be sync? - I like to think so
      xhr.open("GET", window.location, true);
      xhr.send();
    }
    document.body.className = 'view-source';
 
    var sourceTimer = setInterval(function () {
      if (window.location.hash != '#view-source') {
        clearInterval(sourceTimer);
        document.body.className = '';
      }
    }, 200);
  }
});
 
})();
 
and
html5demos.css
 
body {
  font: normal 16px/20px "Helvetica Neue", Helvetica, sans-serif;
  background: rgb(237, 237, 236);
  margin: 0;
  margin-top: 40px;
  padding: 0;
}
 
section, header, footer {
  display: block;
}
 
#wrapper {
  width: 600px;
  margin: 0 auto;
  background: #fff url(../images/shade.jpg) repeat-x center bottom;
  -moz-border-radius: 10px;
  -webkit-border-radius: 10px;
  border-radius: 10px;
  border-top: 1px solid #fff;
  padding-bottom: 76px;
}
 
h1 {
  padding-top: 10px;
}
 
h2 {
  font-size: 100%;
  font-style: italic;
}
 
header,
article > *,
footer > * {
  margin: 20px;
}
 
footer > * {
  margin: 20px;
  color: #999;
}
 
#status {
  padding: 5px;
  color: #fff;
  background: #ccc;
}
 
#status.fail {
  background: #c00;
}
 
#status.success {
  background: #0c0;
}
 
#status.offline {
  background: #c00;
}
 
#status.online {
  background: #0c0;
}
 
/*footer #built:hover:after {
  content: '...quickly';
}
*/
[contenteditable]:hover:not(:focus) {
  outline: 1px dotted #ccc;
}
 
abbr {
  border-bottom: 0;
}
 
abbr[title] {
  border-bottom: 1px dotted #ccc;
}
 
li {
  margin-bottom: 10px;
}
 
#promo {
  font-size: 90%;
  background: #333 url(../images/learn-js.jpg) no-repeat left center;
  display: block;
  color: #efefef;
  text-decoration: none;
  cursor: pointer;
  padding: 0px 20px 0px 260px;
  border: 5px solid #006;
  height: 160px;
}
 
#promo:hover {
  border-color: #00f;
}
 
#ih5 {
  font-size: 90%;
  background: #442C0D url(../images/ih5.jpg) no-repeat left center;
  display: block;
  color: #F7FCE4;
  text-decoration: none;
  cursor: pointer;
  padding: 1px 20px 1px 260px;
  border: 5px solid #904200;
}
 
#ih5:hover {
  border-color: #CF6D3B;
}
 
#ffad section {
  padding: 20px;
}
 
#ffad p {
  margin: 10px 10px 10px 100px;
}
 
#ffad img {
  border: 0;
  float: left;
  display: block;
  margin: 14px 14px 0;
}
 
#ffad .definition {
  font-style: italic;
  font-family: Georgia,Palatino,Palatino Linotype,Times,Times New Roman,serif;
}
 
#ffad .url {
  text-decoration: underline;
}
 
button, input {
  font-size: 16px;
  padding: 3px;
  margin-left: 5px;
}
 
#view-source {
  display: none;
}
 
body.view-source {
  margin: 0;
  background: #fff;
  padding: 20px;
}
 
body.view-source > * {
  display: none;
}
 
body.view-source #view-source {
  display: block !important;
  margin: 0;
}
 
#demos {
  width: 560px;
  border-collapse: collapse;
}
 
#demos .demo {
  padding: 5px;
}
 
#demos a {
  color: #00b;
  text-decoration: none;
  font-size: 14px;
}
 
#demos a:hover {
  text-decoration: underline;
}
 
#demos tbody tr {
  border-top: 1px solid #DCDCDC;
}
 

#demos .demo p {
  margin-top: 0;
  margin-bottom: 5px;
}
 
#demos .support {
  width: 126px;
}
 
.support span {
  cursor: pointer;
  overflow: hidden;
  float: left;
  display: block;
  height: 16px;
  width: 16px;
  text-indent: -9999px;
  background-image: url(../images/browsers.gif);
  background-repeat: none;
  margin-right: 5px;
}
 
.support span.selected {
  outline: 1px dashed #75784C;
}
 
.support span.safari {
  background-position: 0 0;
}
 
.support span.chrome {
  background-position: 16px 0;
}
 
.support span.firefox {
  background-position: 32px 0;
}
 
.support span.ie {
  background-position: 48px 0;
}
 
.support span.opera {
  background-position: 64px 0;
}
 
.support span.nightly {
  opacity: 0.5;
  filter:alpha(opacity=50);
}
 
.support span.none {
  opacity: 0.1;
  filter:alpha(opacity=10);
}
 
#demos .tags {
  width: 140px;
}
 
.tags span {
  font-size: 11px;
  color: #6E724E;
  padding: 2px 5px;
  border: 1px solid #D7D999;
  background: #FFFFC6;
  -moz-border-radius: 10px;
  -webkit-border-radius: 10px;
  border-radius: 10px;
  cursor: pointer;
}
 
.tags span:hover,
.tags span.selected {
  border: 1px solid #75784C;
  background: #FF7;
  color: #333521;
}
 
#tags span {
  margin-right: 2px;
}
 
#tags {
  font-size: 14px;
}
 
#html5badge {
/*  display: none;*/
  margin-left: -30px;
  border: 0;
}
 
#html5badge img {
  border: 0;
}
 
.support span.yourbrowser {
  width: 16px;
  height: 16px;
  background: none;
}
 
.support span.yourbrowser.supported {
  background: url(../images/yourbrowser.gif) no-repeat top left;
}
 
.support span.yourbrowser.not-supported {
  background: url(../images/yourbrowser.gif) no-repeat top right;
}
 
#carbonads-container {
  position: fixed;
  margin-left: 620px;
  margin-top: -2px;
}
 
/** Pretty printing styles. Used with prettify.js. */
pre { font-size: 14px; }
.str { color: #080; }
.kwd { color: #008; }
.com { color: #800; }
.typ { color: #606; }
.lit { color: #066; }
.pun { color: #660; }
.pln { color: #000; }
.tag { color: #008; }
.atn { color: #606; }
.atv { color: #080; }
.dec { color: #606; }
 

sorry for my english
Posted 8-Nov-12 9:03am

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

  Print Answers RSS
0 OriginalGriff 277
1 Maciej Los 210
2 BillWoodruff 205
3 Jochen Arndt 180
4 Sergey Alexandrovich Kryukov 165
0 OriginalGriff 5,130
1 DamithSL 4,157
2 Maciej Los 3,670
3 Kornfeld Eliyahu Peter 3,470
4 Sergey Alexandrovich Kryukov 2,821


Advertise | Privacy | Mobile
Web01 | 2.8.141216.1 | Last Updated 8 Nov 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100