[OpenLayers-Users] attaching a control to an external div

P Kishor punkish at eidesis.org
Wed Sep 9 20:39:33 EDT 2009


Per the docs for Control

"Controls by default are added to the map they are contained within
however it is possible to add a control to an external div by passing
the div in the options parameter."

which seems to be completely not like the source code at
http://openlayers.org/dev/examples/mouse-position.html


So, I have the following

<div id="map"></div>
<div id="coords"></div>


<script type="text/javascript">

// The following works, but the mouse position is displayed on the map
var ctrl_coords = new OpenLayers.Control.MousePosition();
map.addControl(ctrl_coords);

// The following does not work
var ctrl_coords = new OpenLayers.Control({div: "coords"});
ctrl_coords.MousePosition();
map.addControl(ctrl_coords);

// The following also does not work
var ctrl_coords = new OpenLayers.Control.MousePosition({div: "coords"});
map.addControl(ctrl_coords);
</script>

Pointers please, as I want to display the mouse position inside the
"coords" div. Does the documentation need to be updated as well?


-- 
Puneet Kishor



More information about the Users mailing list