Drawing a Polygon
Modifying a Polygon
Buttons
Using an Edition Frame
<link rel="stylesheet" href="http://aladin.u-strasbg.fr/AladinLite/api/v2/latest/aladin.min.css" />
<script type="text/javascript" src="http://code.jquery.com/jquery-1.11.3.min.js" charset="utf-8"></script>
<script type="text/javascript" src="http://aladin.u-strasbg.fr/AladinLite/api/v2/latest/aladin.js" charset="utf-8"></script>
<script type="text/javascript" src="saadajsbasics/javascript/Segment.js" charset="utf-8"></script>
<script type="text/javascript" src="saadajsbasics/javascript/AstroCoo.js" charset="utf-8"></script>
<script type="text/javascript" src="saadajsbasics/javascript/RegionEditor_m.js" charset="utf-8"></script>
<script type="text/javascript" src="saadajsbasics/javascript/RegionEditor_v.js" charset="utf-8"></script>
<script type="text/javascript" src="saadajsbasics/javascript/RegionEditor_c.js" charset="utf-8"></script>
The region editor must be initialized in the $.ready() JQuery handler.
$.ready = function() {
regionEditor = new RegionEditor_mVc("aladin-lite-div"
, function(data) {
if (data.userAction)
alert(JSON.stringify(data));
});
regionEditor.init();
}
The JSON below show the way polygons are described.
{ "isReady":true,
"userAction":true,
"region":{
"format":"array2dim",
"points":[[12.88371,-11.182474],[345.964137,-9.737165],[352.89423,10.130681],[12.883716,-11.182474]],
"size":{"x":19.989480,"y":21.313155}}
}
A polygon can be drawn by the API:
regionEditor.setInitialValue(points);
where points has the following form:
{
type : "array",
value : [ 0, 89, 120, 89, 240, 89 ]
}
Edition frames can also be drawn by the API:
regionEditor.setEditionFrame(points);
where points can either have the previous form or the following one:
{
type : "soda",
value : "POLYGON 0 89 120, 89 240 89"
}