I got this Example Map

SampleMap: http://techinfo.co.id/test/map.php

I make Boundary Polygon shape ,

-6.875165174925262, 107.56293296813965
-6.882663904407988, 107.66730308532715
-6.980818117491586, 107.67210960388184
-6.97093546084682, 107.54508018493652

And How to check if the given Lat, Lng is -6.935884,107.611592 in those Boundary Area

But what i need is without Google Maps Api .. because it's gonna be Offline


4 Answers 4


a simple algorithm would consist in checking that you are on the "good" side of the lines that build your polygon. For instance, the long of your point has to be larger than the long of the West side and smaller than the long of your East side at the lat of your point.


Long_point >  Long_LowerLeft + Lat_point * ( Long_UpperLeft - Long_LowerLeft)/ ( Lat_UpperLeft - Lat_LowerLeft)

for more complex shapes, you need to draw a line from your point (in any arbitrary direction) and you are inside if the number of intersection with the sides of your polygon is uneven.


Although your question probably is harder than it seems due to curvature (spheical trig) issues, if you're happy to ignore that, there are a few ways to do a point-in-polygon check. I've used a ray casting algorithm, and you should be able to find example code somewhere to do that.

If you're using Python, just use Shapely. If Javascript, here's some code.


I found the correct answer here ...

it's tested many times and works like a charm



You can do this type of thing using GDAL/OGR library in python. Can also do it with the excellent jsts library https://github.com/bjornharrtell/jsts in javascript.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.