[OpenLayers-Users] center crosshairs?
geoman
csabbey at gmail.com
Tue Sep 9 14:21:16 EDT 2008
Hello,
I am trying to add a icon that is fixed at the center of a map, to show
where the center is when people are zooming. I didn't see a way to add an
icon to a map directly, and it looks like if I put the icon in a marker and
then add that to a layer on the map then the icon will move with the map.
My solution was to add the icon through the DOM (using Prototype:)
var centerIcon = new Element("img");
centerIcon.src = "img/center5.gif";
centerIcon.id = "mapCenter";
centerImg.setStyle({
left: ((document.viewport.getWidth() / 2) - (centerImg.getWidth() / 2))
+ 'px',
top: ((document.viewport.getHeight() / 2) - (centerImg.getHeight() /
2)) + 'px'
});
$('map_OpenLayers_ViewPort').insert(centerIcon);
Here is the styling I used for this element:
img#mapCenter {
position: absolute;
z-index: 10000;
}
Is there a way to do this using the OpenLayers API? If not, can you offer
any solutions with a couple major problems I see with the above approach:
1. The icon isn't always at the center of the map; it is always close, but
when I zoom in I can tell it is slightly high and to the left. I'm not sure
why it is usually dead-center and sometimes off-center.
2. Markers under the icon no longer receive mouse events. I tried to set the
z-index of the icon so it would be under my marker layer, but my
map_OpenLayers_Container has a z-index of 749 and my marker layer has a
z-index of 350, and I can't set the z-index both above 749 (so the icon is
visible over the map tiles) and below 350 (so the markers will receive input
events).
Thanks in advance,
Craig
--
View this message in context: http://www.nabble.com/center-crosshairs--tp19398206p19398206.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
More information about the Users
mailing list