Skip to content

Commit

Permalink
update sample map
Browse files Browse the repository at this point in the history
  • Loading branch information
andygup committed Aug 17, 2016
1 parent 10a56b5 commit 880f1b5
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 18 deletions.
27 changes: 13 additions & 14 deletions sample/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,12 @@ var app = {
var satellites = "<br /><span style='font-weight:bold;'>Satellite Data:</span> " + date.toUTCString() + "<br /><br />";

for( var key in json){
if(json.hasOwnProperty(key) && key.toLowerCase() != "provider" && key.toLowerCase() != "timestamp"){

if(json.hasOwnProperty(key)
&& key.toLowerCase() != "provider"
&& key.toLowerCase() != "timestamp"
&& key.toLowerCase() != "error"){

satellites +=
"PRN: " + json[key].PRN +
", fix: " + json[key].usedInFix +
Expand All @@ -101,15 +106,6 @@ var app = {
satDiv.innerHTML = satellites;
}

function addLocationData(lat, lon, provider){
locationDiv.innerHTML =
lat
+ ", "
+ lon
+ ": "
+ provider;
}

// Initialize the geolocation plugin
function init(){
synchronizeMap();
Expand All @@ -132,18 +128,21 @@ var app = {
switch(jsonObject.provider){
case "gps":
if(jsonObject.latitude != "0.0"){
var point = new Point(jsonObject.longitude, jsonObject.latitude, "GPS");
console.log("GPS location detected - lat:" +
jsonObject.latitude + ", lon: " + jsonObject.longitude);
var point = new Point(jsonObject.longitude, jsonObject.latitude);
map.centerAt(point);
addGraphic( greenGPSSymbol, point);
}
break;

case "network":
if(jsonObject.latitude != "0.0"){
console.log("Network location detected - lat:" +
jsonObject.latitude + ", lon: " + jsonObject.longitude);
var point = new Point(jsonObject.longitude, jsonObject.latitude);
map.centerAt(point);
addGraphic( blueNetworkSymbol, point);
addLocationData(jsonObject.longitude, jsonObject.latitude, "NETWORK");
}
break;

Expand All @@ -168,9 +167,9 @@ var app = {
}
},
function(error){
console.log("ERROR! " + JSON.stringify(error));
console.log("Error JSON: " + JSON.stringify(error));
var e = JSON.parse(error);
console.log("Error: " + e.msg);
console.log("Error no.: " + e.error + ", Message: " + e.msg + ", Provider: " + e.provider);
},
/////////////////////////////////////////
//
Expand Down
8 changes: 4 additions & 4 deletions sample/sample-map.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, user-scalable=no"/>
<title>Hello World Map</title>
<link rel="stylesheet" href="https://js.arcgis.com/3.16/esri/css/esri.css">
<link rel="stylesheet" href="https://js.arcgis.com/3.17/esri/css/esri.css">
<style>
html, body, #map {
height: 75%;
Expand All @@ -54,14 +54,14 @@
font-family: "Trebuchet MS";
}
</style>
<script src="https://js.arcgis.com/3.16/"></script>
<script src="https://js.arcgis.com/3.17/"></script>
</head>
<body>
<div id="map"></div>
<hr>
<div>
GPS&nbsp; <img src="img/blue-pin.png">
&nbsp;NETWORK&nbsp; <img src="img/green-pin.png">
GPS&nbsp; <img src="img/green-pin.png">
&nbsp;NETWORK&nbsp; <img src="img/blue-pin.png">
</div>
<hr>
<div id='locationData'></div>
Expand Down

0 comments on commit 880f1b5

Please sign in to comment.