<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">

<head>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii">
<meta name=Generator content="Microsoft Word 12 (filtered medium)">
<style>
<!--
 /* Font Definitions */
 @font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:10.0pt;
        font-family:"Arial","sans-serif";
        color:#003082;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:"Arial","sans-serif";
        color:#003082;}
.MsoChpDefault
        {mso-style-type:export-only;}
@page Section1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.Section1
        {page:Section1;}
-->
</style>
<!--[if gte mso 9]><xml>
 <o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
 <o:shapelayout v:ext="edit">
  <o:idmap v:ext="edit" data="1" />
 </o:shapelayout></xml><![endif]-->
</head>

<body lang=EN-GB link=blue vlink=purple>

<div class=Section1>

<p class=MsoNormal>Hi all,<o:p></o:p></p>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

<p class=MsoNormal>Im fairly new to OpenLayers and &nbsp;javascript for that matter
as well.&nbsp; Having looked extensively through all the various examples and
forums and blogs, and one or 2 tutorials, I am still struggling to add a point
to a map (or a vector layer)!&nbsp; All I want, is to click on a map and adda a
point.&nbsp; Heres my code, please feel free to point all the errors you want!<o:p></o:p></p>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

<p class=MsoNormal>Thanks in advance!<o:p></o:p></p>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

<p class=MsoNormal>Chris<o:p></o:p></p>

<p class=MsoNormal>(Sorry if this has been sent twice)<o:p></o:p></p>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-family:"Courier New";
color:windowtext'><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-family:"Courier New";
color:blue'>var</span><span style='font-family:"Courier New";color:windowtext'>
myStyles = </span><span style='font-family:"Courier New";color:blue'>new</span><span
style='font-family:"Courier New";color:windowtext'> OpenLayers.StyleMap({<o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-family:"Courier New";
color:windowtext'>&nbsp;&nbsp;&nbsp; </span><span style='font-family:"Courier New";
color:#A31515'>&quot;default&quot;</span><span style='font-family:"Courier New";
color:windowtext'>: </span><span style='font-family:"Courier New";color:blue'>new</span><span
style='font-family:"Courier New";color:windowtext'> OpenLayers.Style({<o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-family:"Courier New";
color:windowtext'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; fillColor: </span><span
style='font-family:"Courier New";color:#A31515'>&quot;#ffcc66&quot;</span><span
style='font-family:"Courier New";color:windowtext'>,<o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-family:"Courier New";
color:windowtext'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; strokeColor: </span><span
style='font-family:"Courier New";color:#A31515'>&quot;#ff9933&quot;</span><span
style='font-family:"Courier New";color:windowtext'>,<o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-family:"Courier New";
color:windowtext'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; strokeWidth: 10<o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-family:"Courier New";
color:windowtext'>&nbsp;&nbsp;&nbsp; })<o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-family:"Courier New";
color:windowtext'>});<o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-family:"Courier New";
color:windowtext'><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-family:"Courier New";
color:blue'>function</span><span style='font-family:"Courier New";color:windowtext'>
initialiseMap(){<o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-family:"Courier New";
color:windowtext'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; map = </span><span
style='font-family:"Courier New";color:blue'>new</span><span style='font-family:
"Courier New";color:windowtext'> OpenLayers.Map(</span><span style='font-family:
"Courier New";color:#A31515'>'map'</span><span style='font-family:"Courier New";
color:windowtext'>);<o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-family:"Courier New";
color:windowtext'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; map.addControl(</span><span
style='font-family:"Courier New";color:blue'>new</span><span style='font-family:
"Courier New";color:windowtext'> OpenLayers.Control.LayerSwitcher());<o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-family:"Courier New";
color:windowtext'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span
style='font-family:"Courier New";color:blue'>var</span><span style='font-family:
"Courier New";color:windowtext'> gphy = </span><span style='font-family:"Courier New";
color:blue'>new</span><span style='font-family:"Courier New";color:windowtext'>
OpenLayers.Layer.Google(<o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-family:"Courier New";
color:windowtext'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span><span style='font-family:"Courier New";color:#A31515'>&quot;Google
Physical&quot;</span><span style='font-family:"Courier New";color:windowtext'>,<o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-family:"Courier New";
color:windowtext'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
{ type: G_PHYSICAL_MAP }<o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-family:"Courier New";
color:windowtext'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
);<o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-family:"Courier New";
color:windowtext'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span
style='font-family:"Courier New";color:blue'>var</span><span style='font-family:
"Courier New";color:windowtext'> gmap = </span><span style='font-family:"Courier New";
color:blue'>new</span><span style='font-family:"Courier New";color:windowtext'>
OpenLayers.Layer.Google(<o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-family:"Courier New";
color:windowtext'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span><span style='font-family:"Courier New";color:#A31515'>&quot;Google
Streets&quot;</span><span style='font-family:"Courier New";color:windowtext'>, </span><span
style='font-family:"Courier New";color:green'><o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-family:"Courier New";
color:windowtext'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
{numZoomLevels: 20 }<o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-family:"Courier New";
color:windowtext'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
);<o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-family:"Courier New";
color:windowtext'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span
style='font-family:"Courier New";color:blue'>var</span><span style='font-family:
"Courier New";color:windowtext'> ghyb = </span><span style='font-family:"Courier New";
color:blue'>new</span><span style='font-family:"Courier New";color:windowtext'>
OpenLayers.Layer.Google(<o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-family:"Courier New";
color:windowtext'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span><span style='font-family:"Courier New";color:#A31515'>&quot;Google
Hybrid&quot;</span><span style='font-family:"Courier New";color:windowtext'>,<o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-family:"Courier New";
color:windowtext'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
{ type: G_HYBRID_MAP, numZoomLevels: 20 }<o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-family:"Courier New";
color:windowtext'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
);<o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-family:"Courier New";
color:windowtext'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span
style='font-family:"Courier New";color:blue'>var</span><span style='font-family:
"Courier New";color:windowtext'> gsat = </span><span style='font-family:"Courier New";
color:blue'>new</span><span style='font-family:"Courier New";color:windowtext'>
OpenLayers.Layer.Google(<o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-family:"Courier New";
color:windowtext'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span><span style='font-family:"Courier New";color:#A31515'>&quot;Google
Satellite&quot;</span><span style='font-family:"Courier New";color:windowtext'>,<o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-family:"Courier New";
color:windowtext'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
{ type: G_SATELLITE_MAP, numZoomLevels: 20 }<o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-family:"Courier New";
color:windowtext'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
);<o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-family:"Courier New";
color:windowtext'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
map.addLayers([gphy, gmap, ghyb, gsat]);<o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-family:"Courier New";
color:windowtext'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
map.setCenter(</span><span style='font-family:"Courier New";color:blue'>new</span><span
style='font-family:"Courier New";color:windowtext'> OpenLayers.LonLat(-74.0094,
40.7048), 5);<o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-family:"Courier New";
color:windowtext'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
map.addControl(</span><span style='font-family:"Courier New";color:blue'>new</span><span
style='font-family:"Courier New";color:windowtext'>
OpenLayers.Control.PanZoomBar());<o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-family:"Courier New";
color:windowtext'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
map.addControl(</span><span style='font-family:"Courier New";color:blue'>new</span><span
style='font-family:"Courier New";color:windowtext'>
OpenLayers.Control.MousePosition());<o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-family:"Courier New";
color:windowtext'>}<o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-family:"Courier New";
color:green'><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-family:"Courier New";
color:green'><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-family:"Courier New";
color:green'><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-family:"Courier New";
color:blue'>function</span><span style='font-family:"Courier New";color:windowtext'>
singleClickButton() {<o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-family:"Courier New";
color:windowtext'>&nbsp;&nbsp;&nbsp; document.getElementById(</span><span
style='font-family:"Courier New";color:#A31515'>&quot;map&quot;</span><span
style='font-family:"Courier New";color:windowtext'>).childNodes[0].style.cursor
= </span><span style='font-family:"Courier New";color:#A31515'>&quot;crosshair&quot;</span><span
style='font-family:"Courier New";color:windowtext'>;<o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-family:"Courier New";
color:windowtext'>&nbsp;&nbsp;&nbsp; map.events.register(</span><span
style='font-family:"Courier New";color:#A31515'>'click'</span><span
style='font-family:"Courier New";color:windowtext'>, </span><span
style='font-family:"Courier New";color:#A31515'>''</span><span
style='font-family:"Courier New";color:windowtext'>, singleClickEvent); <o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-family:"Courier New";
color:windowtext'><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-family:"Courier New";
color:windowtext'>}<o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-family:"Courier New";
color:windowtext'><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-family:"Courier New";
color:blue'>function</span><span style='font-family:"Courier New";color:windowtext'>
singleClickEvent (e) {<o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-family:"Courier New";
color:windowtext'>&nbsp;&nbsp;&nbsp; </span><span style='font-family:"Courier New";
color:blue'>var</span><span style='font-family:"Courier New";color:windowtext'>
lonlat = map.getLonLatFromViewPortPx(e.xy);<o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-family:"Courier New";
color:windowtext'>&nbsp;&nbsp;&nbsp; </span><span style='font-family:"Courier New";
color:blue'>var</span><span style='font-family:"Courier New";color:windowtext'>
lon = lonlat.lon<o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-family:"Courier New";
color:windowtext'>&nbsp;&nbsp;&nbsp; </span><span style='font-family:"Courier New";
color:blue'>var</span><span style='font-family:"Courier New";color:windowtext'>
lat = lonlat.lat<o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-family:"Courier New";
color:windowtext'><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-family:"Courier New";
color:windowtext'>&nbsp;&nbsp;&nbsp; </span><span style='font-family:"Courier New";
color:blue'>var</span><span style='font-family:"Courier New";color:windowtext'>
pointLayer = </span><span style='font-family:"Courier New";color:blue'>new</span><span
style='font-family:"Courier New";color:windowtext'> OpenLayers.Layer.Vector(</span><span
style='font-family:"Courier New";color:#A31515'>'Points'</span><span
style='font-family:"Courier New";color:windowtext'>, { styleMap: myStyles });<o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-family:"Courier New";
color:windowtext'>&nbsp;&nbsp;&nbsp; map.addLayers([pointLayer]);<o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-family:"Courier New";
color:windowtext'>&nbsp;&nbsp;&nbsp; </span><span style='font-family:"Courier New";
color:blue'>var</span><span style='font-family:"Courier New";color:windowtext'>
bPoint = </span><span style='font-family:"Courier New";color:blue'>new</span><span
style='font-family:"Courier New";color:windowtext'>
OpenLayers.Geometry.Point(lon , lat)<o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-family:"Courier New";
color:windowtext'>&nbsp;&nbsp;&nbsp; newpoint = </span><span style='font-family:
"Courier New";color:blue'>new</span><span style='font-family:"Courier New";
color:windowtext'> OpenLayers.Feature.Vector(bPoint);<o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-family:"Courier New";
color:windowtext'>&nbsp;&nbsp;&nbsp; pointLayer.addFeatures(newpoint);<o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-family:"Courier New";
color:windowtext'>&nbsp;&nbsp;&nbsp; <o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-family:"Courier New";
color:windowtext'>}<o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-family:"Courier New";
color:windowtext'><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-family:"Courier New";
color:windowtext'><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-family:"Courier New";
color:windowtext'><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-family:"Courier New";
color:windowtext'><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal>&nbsp;<o:p></o:p></p>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

</div>

</body>

</html>

<table><tr><td bgcolor=#ffffff><font color=#000000>IMPORTANT - This email and the information that it contains may be confidential, legally privileged and protected by law. Access by the intended recipient only is authorised. Any liability (in negligence or otherwise) arising from any third party acting, or refraining from acting, on any information contained in this email is hereby excluded. If you are not the intended recipient, please notify AmlinCommunications@amlin.co.uk immediately then delete it and do not disclose the contents to any other person, use it for any purpose or store or copy the information in any medium.<br>
<br>
Copyright in this email and attachments created by us belong to Amlin plc and/or one or more of its subsidiaries (Amlin Group). The author also asserts the right to be identified as such and object to any misuse.<br>
</font></td></tr></table>
<table><tr><td bgcolor=#ffffff><font color=#000000>The Amlin Group prohibits and takes steps to prevent its email systems from being used to view, store or transmit offensive, obscene or discriminatory material. If this message contains inappropriate material please report it immediately to AmlinCommunications@amlin.co.uk.<br>
<br>
The Amlin Group records, monitors and may inspect messages that use its telecoms systems in order to protect its information, interests and reputation. Any message sent by you to or within the Amlin Group may therefore be viewed and may be acted upon.<br>
<br>
Of the companies within the Amlin Group, Amlin Underwriting Limited, Amlin Underwriting Services Limited, Amlin UK Limited and Amlin Plus Limited are authorised and regulated by the Financial Services Authority.<br>
</font></td></tr></table>
<table><tr><td bgcolor=#ffffff><font color=#000000>This email has been sent by a member of staff of one or more of the following Amlin Group companies:<br>
<br>
Amlin plc. Registered in England and Wales no. 2854310<br>
Amlin Underwriting Limited. Registered in England and Wales no. 2323018<br>
Amlin Underwriting Services Limited. Registered in England and Wales no. 422615<br>
Amlin UK Limited. Registered in England and Wales no. 2739220<br>
Amlin Plus Limited. Registered in England and Wales no. 4729659<br>
<br>
Registered Offices: St Helen's, 1 Undershaft, London EC3A 8ND, United Kingdom<br>
<br>
Amlin plc switchboard: 020 7746 1000 <br>
Web Site: http://www.amlin.com<br>
</font></td></tr></table>