Start a new topic

POI Web Service Android

POI Web Service Android

1 person has this problem


Can you please describe the issue in more detail?
The dummy-POI service used in the SDK sample application returns random POIs close to a given position, e.g.
https://example.wikitude.com/GetSamplePois/?lat=33.06068&lon=-97.50336&nrPois=1
when you implement your own service you can do something similar.
The "ERR_CONNECTION_REFUSED" error is not reproducible on the dummy POI service, so I guess your own server-service encountered an issue.

Best regards

i'm having ERR_CONNECTION_REFUSED 

 It was the localhost... :v

 

 

 

thank you very much for the help, it worked.

 

 


Hi Antonio!

I guess this was unintentional, but using "localhost" as a server-IP will not work, except you deployed your POI server on your Android device ;-)

Please use LAN IP instead and give it another try.
Also note that this forum is targeting AR-specific questions, pls. use e.g. stackoverflow for jQuery or JSON server related questions.

Best regards,
Andreas

Hi, I could implement the Web service tutorial instance, but when I try to use my own web service I get the error:

"invalid web-service response"

In debug mode, the message is this

"Failed to load resource: net::ERR_CONNECTION_REFUSED"

The code:

// information about server communication. This sample webservice is provided by Wikitude and returns random dummy places near given location
var ServerInformation = {
POIDATA_SERVER: "http://localhost:8094/app-prueba/index.php/ws/Usuario/",
POIDATA_SERVER_ARG_LAT: "lat",
POIDATA_SERVER_ARG_LON: "lon",
POIDATA_SERVER_ARG_NR_POIS: "nrPois"
};

// implementation of AR-Experience (aka "World")
var World = {
// you may request new data from server periodically, however: in this sample data is only requested once
isRequestingData: false,

// true once data was fetched
initiallyLoadedData: false,

// different POI-Marker assets
markerDrawable_idle: null,
markerDrawable_selected: null,
markerDrawable_directionIndicator: null,

// list of AR.GeoObjects that are currently shown in the scene / World
markerList: ,

// The last selected marker
currentMarker: null,

// called to inject new POI data
loadPoisFromJsonData: function loadPoisFromJsonDataFn(poiData) {

// empty list of visible markers
World.markerList = ;

// start loading marker assets
World.markerDrawable_idle = new AR.ImageResource("assets/marker_idle.png");
World.markerDrawable_selected = new AR.ImageResource("assets/marker_selected.png");
World.markerDrawable_directionIndicator = new AR.ImageResource("assets/indi.png");

// loop through POI-information and create an AR.GeoObject (=Marker) per POI
for (var currentPlaceNr = 0; currentPlaceNr < poiData.length; currentPlaceNr++) {
var singlePoi = {
"id": poiData.id,
"latitude": parseFloat(poiData.latitude),
"longitude": parseFloat(poiData.longitude),
"altitude": parseFloat(poiData.altitude),
"title": poiData.name,
"description": poiData.description
};

World.markerList.push(new Marker(singlePoi));
}

World.updateStatusMessage(currentPlaceNr + ' places loaded');
},

// updates status message shon in small "i"-button aligned bottom center
updateStatusMessage: function updateStatusMessageFn(message, isWarning) {

var themeToUse = isWarning ? "e" : "c";
var iconToUse = isWarning ? "alert" : "info";

$("#status-message").html(message);
$("#popupInfoButton").buttonMarkup({
theme: themeToUse
});
$("#popupInfoButton").buttonMarkup({
icon: iconToUse
});
},

// location updates, fired every time you call architectView.setLocation() in native environment
// Note: You may set 'AR.context.onLocationChanged = null' to no longer receive location updates in World.locationChanged.
locationChanged: function locationChangedFn(lat, lon, alt, acc) {

// request data if not already present
if (!World.initiallyLoadedData) {
World.requestDataFromServer(lat, lon);
World.initiallyLoadedData = true;
}
},

// fired when user pressed maker in cam
onMarkerSelected: function onMarkerSelectedFn(marker) {

// deselect previous marker
if (World.currentMarker) {
if (World.currentMarker.poiData.id == marker.poiData.id) {
return;
}
World.currentMarker.setDeselected(World.currentMarker);
}

// highlight current one
marker.setSelected(marker);
World.currentMarker = marker;
},

// screen was clicked but no geo-object was hit
onScreenClick: function onScreenClickFn() {
if (World.currentMarker) {
World.currentMarker.setDeselected(World.currentMarker);
}
World.currentMarker = null;
},

/*
JQuery provides a number of tools to load data from a remote origin.
It is highly recommended to use the JSON format for POI information. Requesting and parsing is done in a few lines of code.
Use e.g. 'AR.context.onLocationChanged = World.locationChanged;' to define the method invoked on location updates.
In this sample POI information is requested after the very first location update.

This sample uses a test-service of Wikitude which randomly delivers geo-location data around the passed latitude/longitude user location.
You have to update 'ServerInformation' data to use your own own server. Also ensure the JSON format is same as in previous sample's 'myJsonData.js'-file.
*/
// request POI data
requestDataFromServer: function requestDataFromServerFn(lat, lon) {

// set helper var to avoid requesting places while loading
World.isRequestingData = true;
World.updateStatusMessage('Requesting places from web-service');

// server-url to JSON content provider
var serverUrl = ServerInformation.POIDATA_SERVER + "?" + ServerInformation.POIDATA_SERVER_ARG_LAT + "=" + lat + "&" + ServerInformation.POIDATA_SERVER_ARG_LON + "=" + lon + "&" + ServerInformation.POIDATA_SERVER_ARG_NR_POIS + "=20";

var jqxhr = $.getJSON(serverUrl, function(data) {
World.loadPoisFromJsonData(data);
})
.error(function(err) {
World.updateStatusMessage("Invalid web-service response.", true);
World.isRequestingData = false;
})
.complete(function() {
World.isRequestingData = false;
});
}

};


/* forward locationChanges to custom function */
AR.context.onLocationChanged = World.locationChanged;

/* forward clicks in empty area to World */
AR.context.onScreenClick = World.onScreenClick;

 

Return from my own Json:



 

Server:

I have use XAMPP

Apache Version Apache/2.4.12 (Win32) OpenSSL/1.0.1l PHP/5.6.8

Thanks.

 

 
Login or Signup to post a comment