1. Home
  2. Docs
  3. GO Map – Documentation
  4. Demo Scenes
  5. Search Location

Search Location

GOToLocationDemo.cs, GOCarAvatar.cs

With this scene I wanted to show another possible use of GOMap that’s not GPS based.

This scene shows a car Avatar that you can move across the map using only a tap (click) gesture and a Search Bar in which you can search for places from all the world or input some coordinates in the lat,lng format.

Of course you’ll notice the new city theme too =)

But let’s see what’s under the hood:

The Search Bar

is a Canvas in which some UI objects are placed together to make an adapting input field with a “dropdown” menu. I suggest you to take a look to the Canvas hierarchy to better understand how it’s (few) components work.

The real job is done inside the GOToLocationDemo.cs component that uses the Mapbox or Mapzen (legacy) search API to reverse geocode addresses into GPS coordinates. It works like any other map search box, for example if you input  “Telegraph Hill” and press GO (or enter key) the API will answer with just an address for “Telegraph Hill, San Francisco, CA, USA” and it’s relative GPS position.

The component will manage to create a new tab under the search bar that will teleport to that location when clicked.

The job of teleporting you to another point of the world and rebuild the map is done with this simple line:

locationManager.SetLocation (location.coordinates);

Where location.coordinates is a classic GOMap style Coordinates.cs object. You can use this line of code whenever you want to change map location by teleporting.

 

An important thing to say it’s about how the LocationManager is set up. The “MotionMode” is set to Avatar and the “Avatar” field is linked with the GOCar Prefab.

This is a classic setup to use the position of a prefab wandering on the map instead of GPS to build the map around your character.

Basically in this way the Locationmanager will monitor the position of your character (car in this case) and accordingly destroy/build portion of map.

GOCarAvatar.cs

is a (very) simple gesture to move a car on the map by your finger. It works fine with the already known GOOrbit.cs allowing you to “steer”.

Feel free to replace it with a real car prefab that uses colliders or whatever you think it’s best for your app/demo =)

 

Was this article helpful to you? Yes No 1

How can we help?