[GIS] how to buffer inside a polygon in Javascript

google mapsjavascriptopenlayers-2

I'd like to know if it's possible to buffer a polygon on the INSIDE only using OpenLayers and other Javascript tools (e.g. jsts).

Here's what I found about the topic in general:

Buffering INSIDE a polygon with ArcGIS (possible):
Inside buffer with attributes in ArcGIS?

Buffering a polygon on BOTH sides with JSTS (possible):
Creating Polyline Buffer in OpenLayers 2?

But I need to buffer a polygon on just the inside. Either a "real" buffer with the output geometry, or a "fake" buffer with just a line thickness and style. However line thickness in OL goes on both sides of the line.

End goal is to get something like this:

enter image description here

Side-question – Does any know if it's possible to do the country outline (like above) via Google Maps API?! Have not been able to find any reference. So I'm trying to duplicate with OpenLayers and a geojson outline of the world.

Best Answer

JSTS is a port of the Java Topology Suite, if it is a faithful port then it should support providing a negative value for the buffer distance. Providing a negative value for the buffer distance will create an inner buffer of the polygon, providing a negative value for a Point or Polyline will create a an empty geometry object.

The challenge is going to be working out the negative value to provide for the distance so when you style the output buffer geometry it gives you the effect you desire. But you should be able to calculate that based on scale and screen resolution.