A function to check the current long & lat are inside set of coordinates?

Hi Outsystems community,

I want to ask if there's a function or forge component to determine the device current location within a set of coordinates?

So this is my case:

  • I've got 6 coordinates (each coordinate contains latitude and longitude) of an area, I already have created a polygon marker using Javascript Maps.
  • I used the Location Plugin for utilizing GPS from the device, and translates the long & lat into GMaps marker.
  • If the marker are inside the area (set of coordinates i've mentioned before), I want to create an output with boolean variable for stating that the current long lat are within the area or not.

For this case, what would I need to achieve those cases? Is there any forge component that suits my requirement or I can create a javascript function based on that? Thanks everyone.

Hi Aditya,

You need something that is demonstrated here:

https://developers.google.com/maps/documentation/javascript/examples/poly-containsLocation 

Regards,

Daniel

Solution

Daniël Kuhlmann wrote:

Hi Aditya,

You need something that is demonstrated here:

https://developers.google.com/maps/documentation/javascript/examples/poly-containsLocation 

Regards,

Daniel

Hi Daniel, thanks for your response.

I found this one: https://www.outsystems.com/forge/component-overview/8197/point-in-polygon 

 is this also can be used for my case?


Solution

Hello Aditya.

Yes, it specifically says "Can be used for a variety of cases i.e. finding if a lat/long point resides within a specific region on a map" so it doesx exactly what you need.

Aditya Eka Prabowo wrote:


Hi Daniel, thanks for your response.

I found this one: https://www.outsystems.com/forge/component-overview/8197/point-in-polygon 

 is this also can be used for my case?


 Hi Aditya,

Good find, I would say, try it out, looks like something useful in your case. If not you can still try and implement the Google Map ContainsLocation function that I shared.

Regards,

Daniel