I need help could not understand why setting the geolocation (also known as) I can not see the point geo-located.
the code is as follows:
function messageClicked() { // set the message DIV text document.getElementById("messageElement").innerHTML = "Loading...";
//var myGeoLocation = new AR.RelativeLocation(null, 5, 0, 0); var myGeoLocation = new AR.GeoLocation(40.8219573, 14.187214100000006, 320.);//BMT mostra d.m. var myGeoLocation2 = new AR.RelativeLocation(myGeoLocation, 10, 0, 0);
var myCircle = new AR.Circle(1, { onClick : function() { alert('Cliccato'); }, style: {fillColor: '#00ABEF'} });
var myGeoObject = new AR.GeoObject(myGeoLocation2, { enabled : false, drawables: {cam: myCircle}});
var myGeoLocation1 = new AR.RelativeLocation(null, 5, 0, 0); var myGeoLocation = new AR.GeoLocation(40.8219573, 14.187214100000006, 320.);//BMT mostra d.m. var myGeoLocation2 = new AR.RelativeLocation(myGeoLocation1, 10, 0, 0);
var myCircle = new AR.Circle(1, { onClick : function() { alert('Cliccato'); }, style: {fillColor: '#00ABEF'} });
var myGeoObject = new AR.GeoObject(myGeoLocation2, { enabled : false, drawables: {cam: myCircle}});
and I can not even squeeze out the alert in LocationChanged.
how could I do?
V
Vincenzo Luongo
said
over 10 years ago
hi,
risucire are to have the coordinates but it takes a bit of time to get the alert but now I do not know how to point out a geo-located .... how could I do?
my function final:
function messageClicked() { // set the message DIV text document.getElementById("messageElement").innerHTML = "Loading...";
AR.context.onLocationChanged = function(lat, lon, alt, acc) { // the current location's latitude, longitude, altitude and accuracy // are passed in by the ARchitect alert('onLocationChanged lat: '+lat+' lon: '+lon); }
var myGeoLocation1 = new AR.RelativeLocation(null, 5, 0, 0); var myGeoLocation = new AR.GeoLocation(40.8219573, 14.187214100000006, 320.);//BMT mostra d.m. var myGeoLocation2 = new AR.RelativeLocation(myGeoLocation1, 10, 0, 0);
var myCircle = new AR.Circle(1, { onClick : function() { alert('Cliccato'); }, style: {fillColor: '#00ABEF'} });
var myGeoObject = new AR.GeoObject(myGeoLocation2, { enabled : false, drawables: {cam: myCircle}});
should be declared outside the messageClicked function. I recommend you to define a userlocation var that holds the current location of the user
var userLocation = null;
AR.context.onLocationChanged = function(lat, lon, alt, acc) { // the current location's latitude, longitude, altitude and accuracy // are passed in by the ARchitect userlocation = {"lat": lat, "lon":lon, "alt":alt, "acc":acc}; // alert('onLocationChanged lat: '+lat+' lon: '+lon); }
Also ensure POI data is only loaded when you already know where user is situated, e.g. request POI-data from server frequently in onLocationChanged function . For easy testing just increment the userLocation's lat and lon values by 0.1, so you can see a sample POI nearby. Do not use AR.RelativeLocation when you want to show POIs at fixed location, only use them for AR.GeoObjects that should move together with an object or the user.
Kind regards, Andreas
T
Timmy Vanuytsel
said
over 10 years ago
Hi,
Today i started with geolocations im my application. Starting with the basics i encountered the same issue's.
It is not an issue when using relative points but the gelocated points refuse to work.
Is this an issue with the static test variables in the native java code?
Greetings Tim
A
Andreas Fötschl
said
over 10 years ago
Hi there!
Did you already checked distance to user as posted in my first reply?
"Keep in mind that by default POIs with distance >50.000m are not rendered. You can adjust this via JS using e.g.
AR.context.scene.cullingDistance = 50500;
"
Also check that you only set "AR.context.onLocationChanged" once. In the provided snipped you overwrote the first event with a maybe invalid assignment to World.locationChanged.
Please also check if you have GPS and WiFi positioning enabled. Also try including "ade.js" in SDK's tool folder (instead of architect://... include) to test your experience in your dektop browser.
Vincenzo Luongo