What is the coordinate system in MDriven (browser location) - mdriven

What is the coordinate system for the values obtained in MDriven ViewModel variables (vLatitude and vLongitude)?

The coordinates from the Angular html5 web client for MDriven are taken from the browser like this:
<script>
var x = document.getElementById("demo");
function getLocation() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(showPosition);
} else {
x.innerHTML = "Geolocation is not supported by this browser.";
}
}
function showPosition(position) {
x.innerHTML = "Latitude: " + position.coords.latitude +
"<br>Longitude: " + position.coords.longitude;
}
</script>
The coordinates are floating point numbers

Related

Microsoft Bing Maps v7 Search Manager GeoCode errorCallBack

The issue happens during page refresh then browser is minimized or its tab with a map is inactive. Then Search Manager geocode function falls into errorCallback. Everything is working fine, if the page with the map is active (visible).
I checked e.request object in the errorCallback function and it contains correct "where" parameter, but no latitude and longitude nor any information about the error.
The issue can be reproduced in both Chrome and IE browsers.
HTML:
<div id="map" class="map" style="height:270px; width:100%"></div>
JavaScript:
<script type="text/javascript" src="https://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=7.0&s=1"></script>
<script type="text/javascript">
// global variables
var apiKey = 'API_KEY_HIDDEN',
map,
searchManager;
// sample data
var siteData = [
{"Name":"Starbucks","Address":"8400 SW Nimbus Ave 120","City":"Beaverton","State":"OR","Zip":"97008","Latitude":0,"Longitude":0},
{"Name":"Subway","Address":"12160 SW Scholls Ferry Rd","City":"Tigard","State":"OR","Zip":"97223","Latitude":0,"Longitude":0}
];
$(document).ready(function () {
GetMap();
setTimeout(function() { location.reload(); }, 60000);
});
function GetMap() {
// initialize the map
map = new Microsoft.Maps.Map(document.getElementById('map'), {
credentials: apiKey,
mapTypeId: Microsoft.Maps.MapTypeId.road,
zoom: 1
});
// load search module
Microsoft.Maps.loadModule('Microsoft.Maps.Search', {
callback: function () {
searchManager = new Microsoft.Maps.Search.SearchManager(map);
$.each(siteData, function(index, clientSite) {
GeoCodeQuery(clientSite);
});
}
});
}
function GeoCodeQuery(clientSite) {
// set search parameters
var searchRequest = {
where: clientSite.Address + ', ' + clientSite.City + ', ' + clientSite.State + ' ' + clientSite.Zip,
callback: function (data) {
if (data && data.results && data.results.length > 0) {
clientSite.Latitude = data.results[0].location.latitude;
clientSite.Longitude = data.results[0].location.longitude;
}
else {
console.log('No results.');
}
},
errorCallback: function (e) {
console.log('Search error.');
}
};
// make the geocode request
searchManager.geocode(searchRequest);
}
</script>
A couple of issues;
You are missing a comma after your where parameter. This would make the searchRequest an invalid JSON object. Fixing this results in the first address being correctly geocoded. The second is throwing an error and this can be for a large number of reasons, the most likely is the next point.
The Bing Maps V7 control was retired in June and will be shut down soon. Some of its backend services are already being taken down and thus it will have issues. You should be using Bing Maps V8 which replaced V7 over a year ago. You can find a migration guide here: https://social.technet.microsoft.com/wiki/contents/articles/34563.bing-maps-v7-to-v8-migration-guide.aspx

How to use the numericRefinementList to set allowed distances?

I would like to be able to use the numericRefinementList to allow users to pick the distance from themselves an item can be? This would be using the IP geo-location feature or inputting the geo-location from browser if available.
Less than 50km
50 - 100km
100 - 150km
More than 150km
https://community.algolia.com/instantsearch.js/documentation/#numericrefinementlist
This is unfortunately not something you can do with the numericRefinementList but you can probably build a custom widget setting the aroundRadius depending on the link you've clicked on:
function radiusList(options) {
if (!options.container) {
throw new Error('radiusList: usage: radiusList({container, ...})');
}
var $container = $(options.container);
if ($container.length === 0) {
throw new Error('radiusList: cannot select \'' + options.container + '\'');
}
return {
init: function(args) {
// event delegation: set the aroundRadius of the underlying link
$(document).on('click', '.radius-link', function(e) {
e.preventDefault();
args.helper.setQueryParameter('aroundRadius', +$(this).data('radius'));
args.helper.search();
});
},
render: function(args) {
// FIXME: display the list of radius links
var html = '<ul>';
html += '<li>< 100km</li>';
html += '</ul>';
$container.html(html);
}
};
}
And then you use it with:
search.addWidget(radiusList({container: '#my-radius-list'}));

Get all directions using Bing Map SDK in UWP

Is it possible to get all driving directions with a specified FROM and TO location in UWP using Bing Map SDK? (just like windows 10 map app)
Yes:
Get a driving or walking route and directions by calling the methods of the MapRouteFinder class - for example, GetDrivingRouteAsync or GetWalkingRouteAsync. The MapRouteFinderResult object contains a MapRoute object that you access through its Route property.
When you request a route, you can specify the following things:
•You can provide a start point and end point only, or you can provide a series of waypoints to compute the route.
•You can specify optimizations - for example, minimize the distance.
•You can specify restrictions - for example, avoid highways.
You can use sample code like this one:
private async void GetRouteAndDirections()
{
// Start at Microsoft in Redmond, Washington.
BasicGeoposition startLocation = new BasicGeoposition();
startLocation.Latitude = 47.643;
startLocation.Longitude = -122.131;
Geopoint startPoint = new Geopoint(startLocation);
// End at the city of Seattle, Washington.
BasicGeoposition endLocation = new BasicGeoposition();
endLocation.Latitude = 47.604;
endLocation.Longitude = -122.329;
Geopoint endPoint = new Geopoint(endLocation);
// Get the route between the points.
MapRouteFinderResult routeResult =
await MapRouteFinder.GetDrivingRouteAsync(
startPoint,
endPoint,
MapRouteOptimization.Time,
MapRouteRestrictions.None);
if (routeResult.Status == MapRouteFinderStatus.Success)
{
// Display summary info about the route.
tbOutputText.Inlines.Add(new Run()
{
Text = "Total estimated time (minutes) = "
+ routeResult.Route.EstimatedDuration.TotalMinutes.ToString()
});
tbOutputText.Inlines.Add(new LineBreak());
tbOutputText.Inlines.Add(new Run()
{
Text = "Total length (kilometers) = "
+ (routeResult.Route.LengthInMeters / 1000).ToString()
});
tbOutputText.Inlines.Add(new LineBreak());
tbOutputText.Inlines.Add(new LineBreak());
// Display the directions.
tbOutputText.Inlines.Add(new Run()
{
Text = "DIRECTIONS"
});
tbOutputText.Inlines.Add(new LineBreak());
foreach (MapRouteLeg leg in routeResult.Route.Legs)
{
foreach (MapRouteManeuver maneuver in leg.Maneuvers)
{
tbOutputText.Inlines.Add(new Run()
{
Text = maneuver.InstructionText
});
tbOutputText.Inlines.Add(new LineBreak());
}
}
}
else
{
tbOutputText.Text =
"A problem occurred: " + routeResult.Status.ToString();
}
}
More info here : https://msdn.microsoft.com/en-us/library/windows/apps/xaml/dn631250.aspx#getting_a_route_and_directions

How to add POI with Wikitude?

I'm new for developer AR With POI
I'm using wikitude for developer AR.I do follow from HERE
This code in js file:
var World = {
loaded: false,
init: function initFn() {
AR.context.onLocationChanged = World.onLocationChanged;
},
onLocationChanged: function onLocationChangedFn(latitude, longitude, altitude, accuracy) {
AR.context.onLocationChanged = null;
World.createMarkerAtLocation(latitude + 0.01, longitude - 0.0005, altitude - 0.06);
},
createMarkerAtLocation: function createMarkerAtLocationFn(latitude, longitude, altitude) {
var markerLocation = new AR.GeoLocation(latitude, longitude, altitude);
var markerDrawable = new AR.ImageDrawable(World.markerDrawable, 3);
var markerObject = new AR.GeoObject(markerLocation, {
drawables: {
cam: markerDrawable
}
});
},
worldLoaded: function worldLoadedFn() {
document.body.removeChild(document.getElementById('loadingMessage'));
}
};
World.init();
And I Run in my android.But my app is not show POIs.
My Question
1. How do I did for POI show in my apps
Excuse me!.I'm not good English
Make sure that your device is getting an location. To see if it gets a location you can add the following lines inside the "function onLocationChangedFn"
alert('Location received');
This should pop up a message once a location has been received.

How to get "scrollTop"-value of FB.Canvas.getPageInfo

So far I can alert the "scrollTop"-value of "FB.Canvas.getPageInfo":
FB.Canvas.getPageInfo(
function(info) {
alert('scrollTop: ' + info.scrollTop);
}
);
Now I would like to use this value in one of my functions, but I don't know how.
The following is not working:
function test() {
var fbScrollTop = FB.Canvas.getPageInfo();
alert(fbScrollTop);
}
How can I access the the value?
I don't know if it's useful yet.
But now I can center my divs in my facebook app.
Here is the function:
jQuery.fn.center = function () {
var temp = this;
FB.Canvas.getPageInfo(
function(info) {
$(temp).css("position","absolute");
$(temp).css("top", Math.max(0, ((info.clientHeight - $(temp).outerHeight()) / 2) + info.scrollTop) + "px");
$(temp).css("left", Math.max(0, ((info.clientWidth - $(temp).outerWidth()) / 2) + info.scrollLeft) + "px");
}
);
return this;
}
And I use like that:
var loading = $("#loading");
loading.center();
Just combine both
function test() {
var fbScrollTop;
FB.Canvas.getPageInfo(function(info) {
fbScrollTop = info.scrollTop;
alert(fbScrollTop);
});
}
Most of the methods available in the SDK are asynchronous - this means that the response will not be available until the provided callback is invoked (with the response).