<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML
dir=ltr><HEAD><TITLE>[OpenLayers-Users] How to modify regular polygon</TITLE>
<META http-equiv=Content-Type content="text/html; charset=us-ascii">
<META content="MSHTML 6.00.6000.16735" name=GENERATOR></HEAD>
<BODY>
<DIV align=left><FONT face=Arial size=2><SPAN class=099453016-17112008>I need a
way to allow the user to draw a bounding box on the map but there doesnt
seem to be a builtin way of doing this.</SPAN></FONT></DIV>
<DIV align=left><FONT face=Arial size=2><SPAN class=099453016-17112008>polygon
and regularPolygon are no good because you cant force them to be
straight.</SPAN></FONT></DIV>
<DIV align=left><FONT face=Arial size=2><SPAN
class=099453016-17112008></SPAN></FONT> </DIV>
<DIV align=left><FONT face=Arial><FONT size=2><FONT>I'm attempting to use the
Box Handler to allow the user to draw a bounding box on the map. (code
below)</FONT></FONT></FONT></DIV>
<DIV align=left><FONT face=Arial><FONT size=2><FONT><SPAN
class=099453016-17112008>T</SPAN>he problem im having is that the feature that
ends up being created is suppose to be a polygon with the same bounds produced
by the box,<SPAN
class=099453016-17112008> </SPAN></FONT></FONT></FONT></DIV>
<DIV align=left><FONT><FONT face=Arial size=2>but what i end up with is an
extreamly tiny polygon at 0,0.<SPAN
class=099453016-17112008> </SPAN></FONT></FONT></DIV>
<DIV align=left><FONT><FONT face=Arial size=2>I'm using a google base so i
thought maybe the projection was the culprit,<SPAN
class=099453016-17112008> </SPAN></FONT></FONT></DIV>
<DIV align=left><FONT><FONT face=Arial size=2>but i've tried transforming the
bounds and nothing good seems to come from it.<SPAN
class=099453016-17112008> </SPAN></FONT></FONT></DIV>
<DIV align=left><FONT><FONT><FONT face=Arial><FONT size=2><SPAN
class=099453016-17112008>A</SPAN>ny ideas?<SPAN class=099453016-17112008><FONT
color=#0000ff> </FONT></SPAN></FONT></FONT></FONT></FONT></DIV>
<DIV align=left><FONT><FONT><FONT face=Arial><FONT size=2><SPAN
class=099453016-17112008> </SPAN></FONT></FONT></FONT></FONT></DIV>
<DIV align=left><FONT face=Arial color=#0000ff>var control = new
OpenLayers.Control({</FONT><FONT face="Courier New"></DIV></FONT>
<DIV align=left><FONT face="Courier New"><FONT face=Arial color=#0000ff
size=2> draw: function () {</FONT></DIV></FONT>
<DIV align=left><FONT face="Courier New"><FONT face=Arial color=#0000ff
size=2> this.box = new
OpenLayers.Handler.Box( control,</FONT></DIV></FONT>
<DIV align=left><FONT face="Courier New"><FONT face=Arial color=#0000ff
size=2> {done:
this.notice},</FONT></DIV></FONT>
<DIV align=left><FONT face="Courier New"><FONT face=Arial color=#0000ff
size=2>
{keyMask: OpenLayers.Handler.MOD_SHIFT});</FONT></DIV></FONT>
<DIV align=left><FONT face="Courier New"><FONT face=Arial color=#0000ff
size=2>
this.box.activate();</FONT></DIV></FONT>
<DIV align=left><FONT face=Arial color=#0000ff size=2>
},</FONT></DIV>
<DIV align=left><FONT face="Courier New"><FONT face=Arial color=#0000ff
size=2> notice: function (bounds){</FONT></DIV></FONT>
<DIV align=left><FONT face="Courier New"><FONT face=Arial color=#0000ff
size=2> var geom =
bounds.toGeometry();</FONT></DIV></FONT>
<DIV align=left><FONT face="Courier New"><FONT face=Arial color=#0000ff
size=2> var feature = new
OpenLayers.Feature.Vector(geom);</FONT></DIV></FONT>
<DIV align=left><FONT face="Courier New"><FONT face=Arial color=#0000ff
size=2>
_bboxLayer.addFeatures(feature);</FONT></DIV></FONT>
<DIV align=left><FONT face="Courier New"><FONT face=Arial color=#0000ff
size=2>
_map.zoomToExtent(bounds,true);</FONT></DIV></FONT>
<DIV align=left><FONT face=Arial color=#0000ff size=2>
}</FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2>});</FONT></DIV></BODY></HTML>