Start a new topic

ar.radar with poi

var myJasonData = [{

 "id": "1",

 "longitude": "33.629480",

 "latitude": " 73.089351",

 "description": "IQRA University Mosque",

 "altitude": "100.0",

 "name": "Mosque"

}, {

 "id": "2",

 "longitude": "33.664799",

 "latitude": "73.045429",

 "description": "This is the description of POI#2",

 "altitude": "100.0",

 "name": "ICEPT"

}, {

 "id": "3",

 "longitude": "33.664876",

 "latitude": "73.045057",

 "description": "This is the description of POI#3",

 "altitude": "100.0",

 "name": "BASKET BAll Ground"

}, {

 "id": "4",

 "longitude": "33.664313",

 "latitude": "73.045333",

 "description": "This is the description of POI#4",

 "altitude": "100.0",

 "name": "FOOT BAll ground"

},];

 

poi data local resource

here is adding radar javascript file

// information about server communication. This sample webservice is provided by Wikitude and returns random dummy places near given location

 

 

// 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) {

 

  // show radar & set click-listener

  PoiRadar.show();

  $('#radarContainer').unbind('click');

  $("#radarContainer").click(PoiRadar.clickedRadar);

 

  // 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[currentPlaceNr].id,

    "latitude": parseFloat(poiData[currentPlaceNr].latitude),

    "longitude": parseFloat(poiData[currentPlaceNr].longitude),

    "altitude": parseFloat(poiData[currentPlaceNr].altitude),

    "title": poiData[currentPlaceNr].name,

    "description": poiData[currentPlaceNr].description

   };

 

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

  }

 

  // updates distance information of all placemarks

  World.updateDistanceToUserValues();

 

  World.updateStatusMessage(currentPlaceNr + ' 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.requestDataFromLocal(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);

 },

 

 // fired when user pressed maker in cam

 onMarkerSelected: function onMarkerSelectedFn(marker) {

  World.currentMarker = marker;

 

  // 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 recalcualte this specific distance before we update the UI. */

  if( undefined == marker.distanceToUser ) {

   marker.distanceToUser = marker.markerObject.locations[0].distanceToUser();

  }

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

 

  $("#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;

 },

 

 // request POI data

 requestDataFrom

 requestDataFromLocal: function requestDataFromLocalFn(lat, lon) {

 

  // set helper var to avoid requesting places while loading

           World.loadPoisFromJsonData(myJsonData.js);

 

 

 },

 

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

 

here is main java activity

package com.example.welcome.project;

 

import android.Manifest;

import android.content.pm.PackageManager;

import android.hardware.SensorManager;

import android.location.Location;

import android.location.LocationListener;

import android.support.v4.content.ContextCompat;

import android.support.v7.app.AppCompatActivity;

import android.os.Bundle;

import android.widget.Toast;

 

import com.wikitude.architect.ArchitectStartupConfiguration;

import com.wikitude.architect.ArchitectView;

import com.wikitude.common.permission.PermissionManager;

 

import java.io.IOException;

 

 

 

 

public class MainActivity extends AppCompatActivity {

 

    private ArchitectView architectView;

      Locationprovider locationprovider;

    private boolean injectedPois = false;

 

 

 

    private final ArchitectView.SensorAccuracyChangeListener sensorAccuracyChangeListener = new ArchitectView.SensorAccuracyChangeListener() {

        @Override

        public void onCompassAccuracyChanged(int i) {

 

            if ( i < SensorManager.SENSOR_STATUS_ACCURACY_MEDIUM) {

 

            }

 

 

 

        }

    };

 

 

 

    @Override

    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_main);

        if (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION)

                == PackageManager.PERMISSION_GRANTED) {

            architectView = (ArchitectView) findViewById(R.id.architectView);

            final ArchitectStartupConfiguration config = new ArchitectStartupConfiguration();

 

            config.setLicenseKey("zwMt2njEq1PPMUvIS8X4XDiAIPimnI8dwrJzsmlJjB/L+W2Hfsw0MExg23LF+rXlVkZFb/k+vgC7v2lN3kq4eM85OVPVdaKcs/rGGtGMdUHoW4irgnSiJDinp7csl3DqBCl9MWocu4LGqyLR7EJHUKW4OPBp58PAwUjqFJlX5tVTYWx0ZWRfX1HOo7VHZCYA374LZmvrUtZ73ZyW71oqCpM3DC6GI5wURVMhwFiskKHKoFTuq3qg533+V7c1wGKxwkouWd5+nytxw9qFQJAdZlllGHDJNrti6zWVj69Aa1GOr9/t3VASZlQCGVqeqdeo7URzrQ8A12CbYgHdx6NkOcwTzQrjP5yErI/UEbYz5ZXH3I336itxhygVbhOdSCRKHjYY+H9ZMFeMKxdaaep/bZDnZsPXPt1qfl4Jr7b6K9lg1M5dvktAbwvhzMhWy9TaEEekPx22ODsp1aKokRDEKDLkWt33KaTdc0d3MvT2/YHe2/no6zHhu7q7w3Z2HKQGT1drDzkKxKfz7hpZPmU8z5AwFNqqHQ/Y+LYI1gyEc7w8uPeIyBZbMbx6Rsa1d+T1yej5Ubq5hO++S8YAj2MqGaq0O+t5IEy41bi985vTaQruA10TgDs1LaDYC8XcyCWIInwxKaz0IrnX8ALVFQThf+S6flUpsQcBEq0QaLE5mDM13aeEBWbLH0E4N7lUKrTi+35c8JjJlpgOixxJiu3IHQ==");

            this.architectView.onCreate(config);

            locationprovider = new Locationprovider(this, new LocationListener() {

                @Override

                public void onLocationChanged(Location location) {

                   // if (!injectedPois) {

                      // architectView.callJavascript("myJasonDAta()");

                        if (location != null && architectView != null) {

                            // check if location has altitude at certain accuracy level & call right architect method (the one with altitude information)

                            if (location.hasAltitude() && location.hasAccuracy() && location.getAccuracy() < 7) {

                                architectView.setLocation(location.getLatitude(), location.getLongitude(), location.getAltitude(), location.getAccuracy());

                            } else {

                                architectView.setLocation(location.getLatitude(), location.getLongitude(), location.hasAccuracy() ? location.getAccuracy() : 1000);

                            }

                        }

 

                }

 

 

                @Override

                public void onStatusChanged(String s, int i, Bundle bundle) {

 

                }

 

                @Override

                public void onProviderEnabled(String s) {

 

                }

 

                @Override

                public void onProviderDisabled(String s) {

 

                }

            });

 

        }

    }

    @Override

    protected void onPostCreate(Bundle savedInstanceState)

    {

        super.onPostCreate(savedInstanceState);

        architectView.onPostCreate();

        try {

 

            architectView.load("file:///android_assets/www/poi/hai.html");

        } catch (IOException e) {

            e.printStackTrace();

        }

 

 

    }

    @Override

    protected void onPause()

    {locationprovider.onPause();

          super.onPause();

          architectView.onPause();

        architectView.unregisterSensorAccuracyChangeListener(sensorAccuracyChangeListener);

 

    }

    @Override

    protected void onResume()

    {

        super.onResume();

        architectView.onResume();

        locationprovider.onResume();

        architectView.registerSensorAccuracyChangeListener(sensorAccuracyChangeListener);

    }

    @Override

    protected void onDestroy()

    {

          super.onDestroy();

          architectView.onDestroy();

    }

 

 

 

}

main activity xml

<?xml version="1.0" encoding="utf-8"?>

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"

    xmlns:app="http://schemas.android.com/apk/res-auto"

    xmlns:tools="http://schemas.android.com/tools"

    android:layout_width="match_parent"

    android:layout_height="match_parent"

    tools:context=".MainActivity">

 

    <com.wikitude.architect.ArchitectView android:id="@+id/architectView"

        android:layout_width="fill_parent" android:layout_height="fill_parent"/>

 

</FrameLayout>

 



Hi,


Can you please let us know what issue you're facing in detail? Which SDK version are you working with? What issue do you have and on which platform,...


Thx and greetings

Nicola


1 person likes this

THanks for response.

application open but not showing poi and ar radar on secreen please solve this problem its my final project ..

android studio 3.1.3 windo
compile sdk 26
target sdk 22
run on mobile samsung j1 

Hi,


Did you follow these steps:


1. make sure that the unchanged sample app is working as expected and POIs are shown

2. change the locations (as the sample app is using relative locations) to absolute lat/long values in the sample app and check if the POIs are shown (if this step is already not showing the POIs, then please debug the code and make sure that the lat/long values are the correct ones and they are near you, otherwise you won't see the POIs)

3. once this is working as expected, create your own project code.


Greetings

Nicola


1 person likes this

Thanks for the response..
i am working on it last three day but nothing poi are shown in screen

my main activtiy code is here



public class MainActivity extends AppCompatActivity implements LocationListener {

private ArchitectView architectView;
Locationprovider locationprovider;
// private boolean injectedPois = false;



private final ArchitectView.SensorAccuracyChangeListener sensorAccuracyChangeListener = new ArchitectView.SensorAccuracyChangeListener() {
@Override
public void onCompassAccuracyChanged(int i) {

if ( i < SensorManager.SENSOR_STATUS_ACCURACY_MEDIUM) {

}



}
};



@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
if (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION)
== PackageManager.PERMISSION_GRANTED) {
architectView = (ArchitectView) findViewById(R.id.architectView);
final ArchitectStartupConfiguration config = new ArchitectStartupConfiguration();

config.setLicenseKey("zwMt2njEq1PPMUvIS8X4XDiAIPimnI8dwrJzsmlJjB/L+W2Hfsw0MExg23LF+rXlVkZFb/k+vgC7v2lN3kq4eM85OVPVdaKcs/rGGtGMdUHoW4irgnSiJDinp7csl3DqBCl9MWocu4LGqyLR7EJHUKW4OPBp58PAwUjqFJlX5tVTYWx0ZWRfX1HOo7VHZCYA374LZmvrUtZ73ZyW71oqCpM3DC6GI5wURVMhwFiskKHKoFTuq3qg533+V7c1wGKxwkouWd5+nytxw9qFQJAdZlllGHDJNrti6zWVj69Aa1GOr9/t3VASZlQCGVqeqdeo7URzrQ8A12CbYgHdx6NkOcwTzQrjP5yErI/UEbYz5ZXH3I336itxhygVbhOdSCRKHjYY+H9ZMFeMKxdaaep/bZDnZsPXPt1qfl4Jr7b6K9lg1M5dvktAbwvhzMhWy9TaEEekPx22ODsp1aKokRDEKDLkWt33KaTdc0d3MvT2/YHe2/no6zHhu7q7w3Z2HKQGT1drDzkKxKfz7hpZPmU8z5AwFNqqHQ/Y+LYI1gyEc7w8uPeIyBZbMbx6Rsa1d+T1yej5Ubq5hO++S8YAj2MqGaq0O+t5IEy41bi985vTaQruA10TgDs1LaDYC8XcyCWIInwxKaz0IrnX8ALVFQThf+S6flUpsQcBEq0QaLE5mDM13aeEBWbLH0E4N7lUKrTi+35c8JjJlpgOixxJiu3IHQ==");
this.architectView.onCreate(config);



}
}
@Override
protected void onPostCreate(Bundle savedInstanceState)
{
super.onPostCreate(savedInstanceState);
architectView.onPostCreate();
try {

architectView.load("file:///android_assets/08_PointOfInterest_1_PoiAtLocation/index.html");

} catch (IOException e) {
e.printStackTrace();
}


}
@Override
protected void onPause()
{locationprovider.onPause();
super.onPause();
architectView.onPause();
architectView.unregisterSensorAccuracyChangeListener(sensorAccuracyChangeListener);

}
@Override
protected void onResume()
{
super.onResume();
architectView.onResume();
locationprovider.onResume();
architectView.registerSensorAccuracyChangeListener(sensorAccuracyChangeListener);
}
@Override
protected void onDestroy()
{
super.onDestroy();
architectView.onDestroy();
}


@Override
public void onLocationChanged(Location location) {
if (location != null && architectView != null) {
// check if location has altitude at certain accuracy level & call right architect method (the one with altitude information)
if (location.hasAltitude() && location.hasAccuracy() && location.getAccuracy() < 7) {
architectView.setLocation(location.getLatitude(), location.getLongitude(), location.getAltitude(), location.getAccuracy());
} else {
architectView.setLocation(location.getLatitude(), location.getLongitude(), location.hasAccuracy() ? location.getAccuracy() : 1000);
}
}
}

@Override
public void onStatusChanged(String s, int i, Bundle bundle) {

}

@Override
public void onProviderEnabled(String s) {

}

@Override
public void onProviderDisabled(String s) {

}
} can you please correct it or write its my final projet and i am stuck
Login or Signup to post a comment