ARCore-Location icon indicating copy to clipboard operation
ARCore-Location copied to clipboard

How to put multiple markers .

Open ankurjaincanopus opened this issue 6 years ago • 6 comments

Hii ,

This is not an issue , but i want some help in distance between the current location and marker which i placed in screen. I have placed all marker in AR screen but distance between the current location an markers is not correct. It is showing the distance from last added marker.

Here is the code snippet.


I have put this code into screenView ArrayList<LocationMarker> lm = getAllRibbonsInRenderSurface(); lm.add(layoutLocationMarker); locationScene.mLocationMarkers.addAll(lm);


/** * This method is used for putting all ribbons location. * * @return */ private ArrayList<LocationMarker> getAllRibbonsInRenderSurface() { ArrayList<LocationMarker> lm = new ArrayList<LocationMarker>(); for (int k = 0; k < ribbonArrayList.size(); k++) { layoutLocationMarker = new LocationMarker( ribbonArrayList.get(k).getLongitude(), ribbonArrayList.get(k).getLatitude(), getExampleView(ribbonArrayList.get(k).getRibbonImageName()) );

        // An example "onRender" event, called every frame
        // Updates the layout with the markers distance
        int finalI = k;
        layoutLocationMarker.setRenderEvent(node -> {
            View eView = exampleLayoutRenderable.getView();
            TextView distanceTextView = eView.findViewById(R.id.textView2);
            imageViewRibbonShow = eView.findViewById(R.id.img_ribbon_show);
            double distance = node.getDistance();
            distanceInAr = node.getDistanceInAR();
            if (distanceInAr <= 25.000) {
                if (distanceInAr <= 15.000) {
                    imageViewRibbonShow.setImageDrawable(getResources().getDrawable(R.mipmap.ic_pink_ribbon));
                    imageViewRibbonShow.getBackground().setColorFilter(getResources().getColor(R.color.colorPink), PorterDuff.Mode.SRC_ATOP);

                } else {
                    imageViewRibbonShow.setImageDrawable(getResources().getDrawable(R.mipmap.ic_pink_ribbon));
                    imageViewRibbonShow.getBackground().setColorFilter(getResources().getColor(R.color.colorLightGray), PorterDuff.Mode.SRC_ATOP);
                }


            }

            /*distanceTextView.setText(finalI + "-" + node.getDistanceInAR() + "M");*/

// distanceTextView.setText(roundTwoDecimals(node.getDistanceInAR()) + "M"); distanceTextView.setText((int) node.getDistanceInAR() + "M"); }); lm.add(layoutLocationMarker); } return lm; }

Please help , thanks in advance.

ankurjaincanopus avatar Sep 29 '18 08:09 ankurjaincanopus

you can see here how to add multiple markers to scene. #20

basitsaleemmb avatar Oct 05 '18 04:10 basitsaleemmb

Hi @basitsaleemmb i have tried this it works fine and add different object but in my case distance between nodes are incorrect because each time it adds same object at different location that is last object node. but thanks for your answer. In that case i have to create multiple object of ViewRenderable but it is crashing the application when there are more objects.

Code : viewRenderables = new CompletableFuture[ribbonArrayList.size()]; // CompletableFuture<ViewRenderable> exampleLayout1; for (int t = 0; t < ribbonArrayList.size(); t++) { viewRenderables[t] = ViewRenderable.builder() .setView(LocationActivity.this, R.layout.item_ribbon_show) .build(); }

Thanks

ankurjaincanopus avatar Oct 08 '18 11:10 ankurjaincanopus

If it crashes,what does your logcat tell ? post that here..

and if you want to stabilize the anchors at a fixed position / you want to minimize the frequent callbacks from sensor

you can try setting the refresh rate like this

locationScene.setAnchorRefreshInterval(60); locationScene.setMinimalRefreshing(true);

this makes sure that,your nodes will be updated only once in every 60 seconds.

ashif-ismail avatar Oct 09 '18 03:10 ashif-ismail

why I am getting these notifications?

On 5 October 2018 at 10:00, basitsaleemmb [email protected] wrote:

you can see here how to add multiple markers to scene. #20 https://github.com/appoly/ARCore-Location/issues/20

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/appoly/ARCore-Location/issues/48#issuecomment-427242967, or mute the thread https://github.com/notifications/unsubscribe-auth/AbnWXM851USmCOJd1VmxDSE8Emc8rdX0ks5uhuBqgaJpZM4XAaAh .

ankurjaincanopus avatar Oct 09 '18 05:10 ankurjaincanopus

@SheikhZayed Hi if you use setAnchorRefreshInterval the problem you may encounter is that the first initialization of the marker in your scene is surely not precise it takes a little time for the sensor to put it in place so the fact of refresh every 60 seconds will provide you an incorrect display

sorry for my bad english

Shnafon avatar Oct 11 '18 13:10 Shnafon

PLEASE UNFOLLOW ME

On 11 October 2018 at 19:04, Shnafon [email protected] wrote:

@SheikhZayed https://github.com/SheikhZayed Hi if you use setAnchorRefreshInterval the problem you may encounter is that the first initialization of the marker in your scene is surely not precise it takes a little time for the sensor to put it in place so the fact of refresh every 60 seconds will provide you with an incorrect display

sorry for my bad english

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/appoly/ARCore-Location/issues/48#issuecomment-428957305, or mute the thread https://github.com/notifications/unsubscribe-auth/AbnWXN2bs5RRJIJ6AibSgVVt4ZU1w7b_ks5uj0j4gaJpZM4XAaAh .

ankurjaincanopus avatar Oct 11 '18 13:10 ankurjaincanopus