Start a new topic

POIs not loaded in presenting deatils documentation

I am using wikitude browsing_poi_presenting-details document (this). It doesn't show POIs but only prompt 'trying to find out where you are'. How to solve this problem? Here is my presentingdetails.js code.

// information about server communication. This sample webservice is provided by Wikitude and returns random dummy places near given location
var ServerInformation = {
	POIDATA_SERVER: "https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=21.753209,72.135907&radius=500&type=restaurant&key=AIzaSyC7FsSDIo0-IeEGEVRqZ-QMfxDZ7_1Awe0",
};

// 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,

	locationUpdateCounter: 0,
	updatePlacemarkDistancesEveryXLocationUpdates: 10,

	// 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");


//World.updateStatusMessage( 'before places loaded');
		// loop through POI-information and create an AR.GeoObject (=Marker) per POI
		for (var currentPlaceNr = 0; currentPlaceNr < poiData.results.length; currentPlaceNr++) {
        		var singlePoi = {
        				"id": poiData.results[currentPlaceNr].id,
                        "latitude": parseFloat(poiData.results[currentPlaceNr].geometry.location.lat),
                        "longitude": parseFloat(poiData.results[currentPlaceNr].geometry.location.lng),
                        "altitude":parseFloat(poiData.results[currentPlaceNr].geometry.location.alt),
                        "title": poiData.results[currentPlaceNr].name,
                        "description": poiData.results[currentPlaceNr].vicinity
        			};

        			World.markerList.push(new Marker(singlePoi));
                    World.updateStatusMessage(currentPlaceNr + ' places loaded');
                }
		// updates distance information of all placemarks
		World.updateDistanceToUserValues();

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

	// sets/updates distances of all makers so they are available way faster than calling (time-consuming) distanceToUser() method all the time
	updateDistanceToUserValues: function updateDistanceToUserValuesFn() {
		for (var i = 0; i < World.markerList.length; i++) {
			World.markerList[i].distanceToUser = World.markerList[i].markerObject.locations[0].distanceToUser();
		}
	},

	// updates status message shown 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
	locationChanged: function locationChangedFn(lat, lon, alt, acc) {

		// request data if not already present
		if (!World.initiallyLoadedData) {
			World.requestDataFromServer(lat, lon);
			World.initiallyLoadedData = true;
		} else if (World.locationUpdateCounter === 0) {
			// update placemark distance information frequently, you max also update distances only every 10m with some more effort
			World.updateDistanceToUserValues();
		}

		// helper used to update placemark information every now and then (e.g. every 10 location upadtes fired)
		World.locationUpdateCounter = (++World.locationUpdateCounter % World.updatePlacemarkDistancesEveryXLocationUpdates);
	},

	/*
		POIs usually have a name and sometimes a quite long description.
		Depending on your content type you may e.g. display a marker with its name and cropped description but allow the user to get more information after selecting it.
	*/

	// fired when user pressed maker in cam
	onMarkerSelected: function onMarkerSelectedFn(marker) {
		World.currentMarker = marker;

		/*
			In this sample a POI detail panel appears when pressing a cam-marker (the blue box with title & description),
			compare index.html in the sample's directory.
		*/
		// update panel values
		$("#poi-detail-title").html(marker.poiData.title);
		$("#poi-detail-description").html(marker.poiData.description);


		// It's ok for AR.Location subclass objects to return a distance of `undefined`. In case such a distance was calculated when all distances were queried in `updateDistanceToUserValues`, we recalculate this specific distance before we update the UI.
		if( undefined == marker.distanceToUser ) {
			marker.distanceToUser = marker.markerObject.locations[0].distanceToUser();
		}

		// distance and altitude are measured in meters by the SDK. You may convert them to miles / feet if required.
		var distanceToUserValue = (marker.distanceToUser > 999) ? ((marker.distanceToUser / 1000).toFixed(2) + " km") : (Math.round(marker.distanceToUser) + " m");

		$("#poi-detail-distance").html(distanceToUserValue);

		// show panel
		$("#panel-poidetail").panel("open", 123);

		$(".ui-panel-dismiss").unbind("mousedown");

		// deselect AR-marker when user exits detail screen div.
		$("#panel-poidetail").on("panelbeforeclose", function(event, ui) {
			World.currentMarker.setDeselected(World.currentMarker);
		});
	},

	// screen was clicked but no geo-object was hit
	onScreenClick: function onScreenClickFn() {
		// you may handle clicks on empty AR space too
	},

	// returns distance in meters of placemark with maxdistance * 1.1
	getMaxDistance: function getMaxDistanceFn() {

		// sort places by distance so the first entry is the one with the maximum distance
		World.markerList.sort(World.sortByDistanceSortingDescending);

		// use distanceToUser to get max-distance
		var maxDistanceMeters = World.markerList[0].distanceToUser;

		// return maximum distance times some factor >1.0 so ther is some room left and small movements of user don't cause places far away to disappear.
		return maxDistanceMeters * 1.1;
	},

	/*
		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;

		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;
			});
	},

	// helper to sort places by distance
	sortByDistanceSorting: function(a, b) {
		return a.distanceToUser - b.distanceToUser;
	},

	// helper to sort places by distance, descending
	sortByDistanceSortingDescending: function(a, b) {
		return b.distanceToUser - a.distanceToUser;
	}

};


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

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

 

 


Hi,


This message is shown when your location can not be fetched as needed. The "i" icon Trying to find out where you are means the app is waiting for location info. If it keeps showing that, it may be because your GPS is not open or you are testing in house and sometimes that blocks/affects the signal.

Please make sure that you have the location services on for the sample app. The location service has to be authorized by the user (so you can check your phone settings for the app if the location service is enabled to the specific app). For the location handling and the correct set-up please check the set-up guide to make sure you have everything done correctly. 


Finally, this could also happen because of specific requirements that your device fail to complete. You could try our sample app with several phones and see if this is happening with other phones as well. The minimum requirements that a device should fulfill are:

  1. Compass
  2. GPS and/or networking positioning
  3. Accelerometer

Thanks

Eva

Thanks for your quick reply Everything is working perfectly when i am using documentation of obtainingdata from web service and it display correct POIs. So when i am developing app using presenting datail documentation obviously problem is not with location or GPS but something is wrong in presentingdetails.js file

Hi,


In this sample, we load POIs from a json file from a server. So when you are using this example, from where do you load your POIs?


Thanks

Eva

I am loading POIs from web server you can see that link in file

Hi,


Since you are using a different format in your .json file, did you check the values of your variables and if they are correct? For example, I would print the variables in this part

for (var currentPlaceNr = 0; currentPlaceNr < poiData.results.length; currentPlaceNr++) {
            var singlePoi = {
                "id": poiData.results[currentPlaceNr].id,
                        "latitude": parseFloat(poiData.results[currentPlaceNr].geometry.location.lat),
                        "longitude": parseFloat(poiData.results[currentPlaceNr].geometry.location.lng),
                        "altitude":parseFloat(poiData.results[currentPlaceNr].geometry.location.alt),
                        "title": poiData.results[currentPlaceNr].name,
                        "description": poiData.results[currentPlaceNr].vicinity
              };

              World.markerList.push(new Marker(singlePoi));
                    World.updateStatusMessage(currentPlaceNr + ' places loaded');
                }


Again, the error that you are getting implies that the POIs are not loaded, so something is not passing correctly to your file.


Thanks

Eva

Yes i already check that and it is correct even i try json file which contain same value as web service and it is working perfect
After lots of try i finally able to go beyond the messages (it took almost 4-5 min)and now it is displaying 'requesting places from web service'. It also took 4-5min but still not display beyond that messages.

Hello Bhoomi,


I will post below some other forum posts where users were experiencing the same issue with you:

I hope this helps

Eva

sorry but this didn't help me!

 

Hi,


Could you please tell me the exact error message you are getting? Also, could you please send over your json file from where you load your POIs?


Thanks

Eva

Is it available to show full description and other information on every marker ?

Hi Mohamed,


Do you want to have a full description on the POIs that you load?  

Then please read the documentation here.


Thanks

Eva


1 person likes this
Login or Signup to post a comment