Find object through search box with Cesium Js

I am using Cesium and I would like to do a very simple operation. I would like to find an object which I created by typing its name in the search bar on the top right corner. Let's consider for example the Points tutorial present in Sandcastle:

function addPoint() {
   Sandcastle.declare(addPoint);

   viewer.entities.add({
       position : Cesium.Cartesian3.fromDegrees(-75.59777, 40.03883),
       name : 'POINT NAME'
       point : {
           pixelSize : 10,
           color : Cesium.Color.YELLOW
       }
   });
}

If I type POINT NAME in the search bar I do not get any result. How can I find the point using the search bar?

PS: I ask the question also here: https://gis.stackexchange.com/questions/242784/find-object-through-search-box-with-cesium-js

Hi there,

In order to program custom geocoder (the search bar) results, you can attach a data of your choice, as shown in this code example: http://cesiumjs.org/Cesium/Apps/Sandcastle/index.html?src=Custom%20Geocoder.html&label=Showcases

In your case, this means having your entity name and positions available in a json like in the above example.

Hope that helps,

  • Rachel

So does this mean that if I create a .json file with my points (labels, coordinates...) I should just replace the website url with the file path?

Any other changes?

Forgive my ignorance but I am quite a novice in Cesium...

So any update?

I have tried to follow your suggestions but I was not able to reach my goal…

How do you load the .json file?

How do you handle the input in order to find the right object inside of the file?

Thanks for the attention.

Regards,

Federico

Hi Fedrico,

The geocoder json format is standardized in the geospatial world. Check this out: https://developers.google.com/maps/documentation/geocoding/intro

hope that helps,

  • Rachel