Search code examples
.netgoogle-earth-plugin

Google Earth API Draw Polygon on mouse click


I am developing a wep app using google earth api. I want to allow user to draw polygon on mouse click e.g if click on point a then b and then c draw a polygon. And its possible to enable or disable this feature by click on "ON/OFF" button, e.g if I click on "ON" button then allow user to draw polygon and if click on "OFF" then don't allow user to draw. Please assist here.

Thanks in advance.


Solution

  • See the Polyplot example by James Stafford. You should be able to adapt it easily to your needs. http://www.barnabu.co.uk/geapi/polyplot/

    EDIT:

    You can also use the GEarthExtensions library if you are wanting to test if a given point (latitude, longitude) is within the bounds of a given polygon.

    var contains = polygon.containsPoint(
                     new geo.Point(point.getLatitude(), point.getLongitude()));