[OpenLayers-Users] TextLayer with Framecloud popup
Carl Morgan
carl.r.morgan at noaa.gov
Fri Jun 27 14:28:59 EDT 2008
I'm attempting to get my points to plot based on the example Christopher
referenced (http://openlayers.org/dev/examples/sundials.html). 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:
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>
Thanks,
Carl
function init(){
map = new OpenLayers.Map('map');
var gmap = new OpenLayers.Layer.Google(
"Google Streets" // the default
);
// var ghyb = new OpenLayers.Layer.Google(
// "Google Hydrid",
// {type: G_HYBRID_MAP}
// );
map.addLayer(gmap);
map.addLayer(new OpenLayers.Layer.GML("Reports",
"archive/LSR/KML/lsr080626.kml",
{
format: OpenLayers.Format.KML,
formatOptions: {
extractStyles: true,
extractAttributes: true
}
}));
selectControl = new
OpenLayers.Control.SelectFeature(map.layers[1],
{onSelect: onFeatureSelect, onUnselect: onFeatureUnselect});
map.addControl(selectControl);
selectControl.activate();
}
function onPopupClose(evt) {
selectControl.unselect(selectedFeature);
}
function onFeatureSelect(feature) {
selectedFeature = feature;
popup = new OpenLayers.Popup.FramedCloud("chicken",
feature.geometry.getBounds().getCenterLonLat(),
new OpenLayers.Size(100,100),
"<h2>"+feature.attributes.name +
"</h2>" + feature.attributes.description,
null, true, onPopupClose);
feature.popup = popup;
map.addPopup(popup);
}
function onFeatureUnselect(feature) {
map.removePopup(feature.popup);
feature.popup.destroy();
feature.popup = null;
}
Christopher Schmidt wrote:
> On Wed, Jun 25, 2008 at 02:28:20PM -0700, Andrew de klerk wrote:
>
>> 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.
>>
>
> 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: http://openlayers.org/dev/examples/sundials.html
>
> Regards,
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20080627/be300d34/attachment.html
More information about the Users
mailing list