On Fri, May 4, 2012 at 8:23 AM, Keith Wiley wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I want to place a &quot;legend&quot; on the map, effectively an image which stays at a particular pixel-location in the view, without being tied to geographic coordinates (and which doesn&#39;t scale with zoom).  I didn&#39;t see an example that does this.<br>

</blockquote><div><br></div><div style>I asked a similar question not too long ago and the one suggestion I got back was that some combination of css could probably work.  Maybe you could look for an example of how to do the google watermark or attribution I think it&#39;s called.</div>

<div style><br></div><div style>I have to confess that from my perspective css is convoluted and complicated with pieces of the puzzle getting spread through several files -- so it can be difficult to track through all the relevant pieces and get everything figured out -- but maybe that&#39;s just me.  And maybe that&#39;s just the price you pay for developing apps that run inside a web browser.</div>

<div style><br></div><div style>In my case I wasn&#39;t just dropping a static image on the screen, I needed to update the contents (the color, the label text, rotation, etc.)  I&#39;m sure there is still a css-based solution out there I could pursue, but for the short term I did the first thing that made sense to me that I could figure out on my own.</div>

<div style><br></div><div style>So bear with me here -- personally when it comes to drawing things in open-layers, I&#39;ve had (by far) the most luck using points. And then specifying a point type (such as circle, square, or my own custom icon -- which is easy to define.)  I&#39;ve also done this for placing &quot;external graphics&quot; and that&#39;s worked out quite well.   Once the icon/graphic is placed, I can update the label, rotate it, move it, change color, etc. by keeping track of the &quot;style&quot; for each point.  I&#39;ve messed around a bit with polygon features for trying to draw simple things, but I always come back to using points with custom icons or external graphics.</div>

<div style><br></div><div style>To actually place the object in a fixed screen location, I do something like the following (which is a combination of copy/paste out of my own code and manual typing):</div><div style><br>
</div>
<div style>    var pt = new OpenLayers.Geometry.Point(screen_x, screen_y); </div><div style>    var pos = map.getLonLatFromPixel( pt );</div><div style>    var myfeature = myLayer.getFeatureByFid(&quot;feature&quot;);</div>

<div style>    # (note that earlier when I created myfeature and added it to myLayer I placed it at 0, 0 and assigned it a unqiue fid)</div><div style>    myfeature.move( pos )</div><div style><br></div><div style>I&#39;ve done a little work with the ordering of operations when the map recenters which helps the objects to appear fixed, but I haven&#39;t played around with keeping them fixed during a zoom -- I know there are move &amp; zoom call backs so presumably you could always reposition your objects ahead of when the map gets redrawn so they always appear fixed on screen.  Points and external graphics maintain a fixed pixel size independent of zooming so that&#39;s another reason they are nice to use instead of polygons with each individual vertex defined in world coordinate space.</div>

<div style><br></div><div style>Another thing I played with for a different app was to create an empty map with lon/lat coordinates that match the screen pixel space (i.e. 0,0 to screen.width, screen.height).  That then gives you a fixed area to work in so you can do &quot;game&quot; like things -- placing graphics with sensible x, y coordinates, rotating, translating them.</div>

<div style><br></div><div style>What would be interesting is if there was a way to overlay a &quot;map&quot; with this simple screen-matching coordinate system on top of a world map in order to do fixed objects on top of the map, but I haven&#39;t seen a way to do that.  Open-layers is cool and powerful and I&#39;m very grateful for it&#39;s existence -- but it does weave a tangled web of class inheritance and it&#39;s always a challenge to dig through layer after layer of class documentation to try to see if a particular feature or function or piece of data even exists and if so, how to leverage it.</div>

<div style><br></div><div style>I&#39;m just learning openlayers myself here, so I&#39;d love to hear feedback if there are better ways to do this stuff.</div><div style><br></div><div><span style>Curt</span> </div></div>

-- <br><div><div>Curtis Olson:</div><div><a href="http://www.atiak.com" target="_blank">http://www.atiak.com</a> - <a href="http://aem.umn.edu/~uav/" target="_blank">http://aem.umn.edu/~uav/</a></div><div><a href="http://www.flightgear.org" target="_blank">http://www.flightgear.org</a> - <a href="http://gallinazo.flightgear.org" target="_blank">http://gallinazo.flightgear.org</a></div>

</div><br>