0

I'm building an Android app where I need to detect when a user enters or exits an expressway.

I’m using the Google Maps API to track a user’s location in real-time.

How can I identify if the user is on an expressway and detect when they enter or exit highways? Is there a way to do this using Google Maps APIs or another recommend way?

3
  • It is likely that you will need to look into navigation SDKs, not map SDKs. Even then, you will need the navigation SDK to tell you the sort of terrain the vehicle is on, with enough information that you can decide whether or not it qualifies as an expressway. Commented Feb 18 at 17:41
  • Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Commented Feb 18 at 18:08
  • Can I do this using only Android Geocoder, without Google APIs? Commented Feb 24 at 5:56

1 Answer 1

0

You can mark highways with certain color using Map Styles like in this answer and than check color of user position like in that answer. Specifically you can create request for just one pixel map (size=1x1) for your Lat/Lon coords with hidden all features except water and set water color to e.g. pure red (0xFF0000). Something like that:

https://maps.googleapis.com/maps/api/staticmap?&center={YOUR_LAT},{YOUR_LON}&zoom={YOUR_ZOOM}&size=1x1&style=feature:all|visibility:off&style=feature:highways|visibility:on&style=feature:highways|color:0xFF0000&key={YOUR_API_KEY}

Then download it and check the color. If it pure red (0xFF0000) user is on highway, if not - out of it. You need this check time to time to get exactly moment of highway enter/exit.

Sign up to request clarification or add additional context in comments.

2 Comments

Can I do this using only Android Geocoder, without Google APIs?
Yes, but you need coordinates of highways enters/exits.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.