<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
I'm attempting to get my points to plot based on the example
Christopher referenced (<a
href="http://openlayers.org/dev/examples/sundials.html">http://openlayers.org/dev/examples/sundials.html</a>).
Although it appears to plot ok initially, if I pan up and down on the
map, the points will move up or down as well. Is this a problem in the
javascript or could the problem be in the kml file? I've included the
code below hoping someone might see the problem, and here's a link to
the page: <a
href="http://www.erh.noaa.gov/ilm/viewer/plotLSR.html?lat=34.20&lon=-78.8&zoom=8&kmlfile=lsr080626.kml">http://www.erh.noaa.gov/ilm/viewer/plotLSR.html?lat=34.20&lon=-78.8&zoom=8&kmlfile=lsr080626.kml</a><br>
<br>
Thanks,<br>
<br>
Carl<br>
<br>
function init(){<br>
map = new OpenLayers.Map('map');<br>
<br>
var gmap = new OpenLayers.Layer.Google(<br>
"Google Streets" // the default<br>
);<br>
<br>
// var ghyb = new OpenLayers.Layer.Google(<br>
// "Google Hydrid",<br>
// {type: G_HYBRID_MAP}<br>
// );<br>
<br>
map.addLayer(gmap);<br>
map.addLayer(new OpenLayers.Layer.GML("Reports",
"archive/LSR/KML/lsr080626.kml", <br>
{<br>
format: OpenLayers.Format.KML, <br>
formatOptions: {<br>
extractStyles: true, <br>
extractAttributes: true<br>
}<br>
}));<br>
selectControl = new
OpenLayers.Control.SelectFeature(map.layers[1],<br>
{onSelect: onFeatureSelect, onUnselect:
onFeatureUnselect});<br>
<br>
map.addControl(selectControl);<br>
selectControl.activate(); <br>
}<br>
function onPopupClose(evt) {<br>
selectControl.unselect(selectedFeature);<br>
}<br>
function onFeatureSelect(feature) {<br>
selectedFeature = feature;<br>
popup = new OpenLayers.Popup.FramedCloud("chicken", <br>
feature.geometry.getBounds().getCenterLonLat(),<br>
new OpenLayers.Size(100,100),<br>
"<h2>"+feature.attributes.name + "</h2>" +
feature.attributes.description,<br>
null, true, onPopupClose);<br>
feature.popup = popup;<br>
map.addPopup(popup);<br>
}<br>
function onFeatureUnselect(feature) {<br>
map.removePopup(feature.popup);<br>
feature.popup.destroy();<br>
feature.popup = null;<br>
}<br>
<br>
<br>
Christopher Schmidt wrote:
<blockquote cite="mid:20080625215437.GA21946@metacarta.com" type="cite">
<pre wrap="">On Wed, Jun 25, 2008 at 02:28:20PM -0700, Andrew de klerk wrote:
</pre>
<blockquote type="cite">
<pre wrap="">Ok, please forgive my late night googling skills (tired eyes!), and thanks
for the prompt response. If i look at that link you have said:
"Generally, the answer is 'no, and why are you still using a Layer.Text?
Use a Layer.GML with a format: OpenLayers.Format.Text and a
selectFeature control instead.'
The reason why I am using Layer.text is because I specifically don't want my
end users to have to select a tool to click on a feature/marker.
</pre>
</blockquote>
<pre wrap=""><!---->
They shouldn't need to.
var control = new OpenLayers.Control.SelectFeature(layer);
map.addControl(control);
control.activate();
Now the select control is active, and clicks on the features will
activate a popup.
See, for example: <a class="moz-txt-link-freetext" href="http://openlayers.org/dev/examples/sundials.html">http://openlayers.org/dev/examples/sundials.html</a>
Regards,
</pre>
</blockquote>
</body>
</html>