FW: OpenLayers Beginners Questions

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

FW: OpenLayers Beginners Questions

Gerd Dowideit
Sorry, had problems with sending this. Gerd


From: Gerd Dowideit [mailto:[hidden email]]
Sent: Sunday, June 17, 2007 1:58 PM
To: '[hidden email]'
Subject: OpenLayers Beginners Questions

Hi All,
I am exploring OpenLayers since a few days and encounter typical beginners problems:
  1. Trying to make use of "Class Documentation" (<A title=blocked::http://dev.openlayers.org/docs/overview-tree.html href="blocked::http://dev.openlayers.org/docs/overview-tree.html">http://dev.openlayers.org/docs/overview-tree.html): the docu is fine, but I do miss information about 'what each entry is good for' and brief examples about 'how to make use'. A list ordered by purpose of classes and functions would also be good. Is there such a list which I have not found yet?
  2. Problem with "var pointLayer = new OpenLayers.Layer.Vector("Point Layer");" and similar (Line and Polygon): All draw controls seem to draw points and vertices south-east of where the mouse-click occurred by about 1/2 of the diameter of the drawn Point-Circle. That means all drawn features are miss-placed. Is this a bug or is it just that I do use the draw feature wrongly? Source attached below. The website is at this stage not public for administrative reasons; sorry.
Cheers,  Gerd
 
__________-___________
 

<html>
<head>
<style type="text/css">
p {
width: 512px;
}
#map {
width: 100%;
height: 100%;
border: 3px solid gray;
}
#controlToggle li {
list-style: none;
}
}
</style>

<script src="./lib/OpenLayers.js"></script>
<script src="Labels.js"></script>

<script type="text/javascript">
<!--
var map, mymouse;
function init(){

// The Map

map = new OpenLayers.Map('map',
{controls: [new OpenLayers.Control.MouseDefaults()] ,
maxResolution: 'auto',
numZoomLevels: 4,
maxExtent: new OpenLayers.Bounds(463934.22,6881911.1,468114.22,6885091.1)});

// ================ Layers ==============================
// The image Base Layer

var topomap = new OpenLayers.Layer.Image(
'Topo Map',
'http://10.0.0.1/www/OL-2-4/Maroon.jpg',
new OpenLayers.Bounds(463934.22,6881911.1,468114.22,6885091.1),
new OpenLayers.Size(1313, 1001),
options);
map.addLayers([topomap]);

// Drawing Layers

var pointLayer = new OpenLayers.Layer.Vector("Point Layer");
map.addLayers([pointLayer]);
var lineLayer = new OpenLayers.Layer.Vector("Line Layer");
map.addLayers([lineLayer]);
var polygonLayer = new OpenLayers.Layer.Vector("Polygon Layer");
map.addLayers([polygonLayer]);


markers = new OpenLayers.Layer.Markers("markers", options);
map.addLayers([markers]);
add_markers();
markers.setVisibility(false);


//=================== Controls =================

map.addControl(new OpenLayers.Control.MousePosition());
map.addControl(new OpenLayers.Control.LayerSwitcher());
map.addControl( new OpenLayers.Control.PanZoomBar() );


// =================== Options ==================

var options = {handlerOptions: {freehand: true}};
drawControls = {
point: new OpenLayers.Control.DrawFeature(pointLayer,
OpenLayers.Handler.Point),
line: new OpenLayers.Control.DrawFeature(lineLayer,
OpenLayers.Handler.Path,options),
polygon: new OpenLayers.Control.DrawFeature(polygonLayer,
OpenLayers.Handler.Polygon,options)
};

for(var key in drawControls) {
map.addControl(drawControls[key]);
}

//=================== Zoom to screen ===================

map.zoomToMaxExtent();
}

//==================================== Functions ==============================




function toggleControl(element) {
for(key in drawControls) {
var control = drawControls[key];
if(element.value == key && element.checked) {
control.activate();
} else {
control.deactivate();
}
}
}

function q11_is(thisform)
{
var Q1_1
with(thisform)
{
Q1_1=value

if(Q1_1==0)
{
Q11_Answer.innerHTML= "<br><br>"
}
else if(Q1_1==1)
{
Q11_Answer.innerHTML= "<br><center><table cellpadding=5 border=1><tr><td>Tool</td><td>Purpose</td></tr><tr><td><img src='Nav_1.jpg'></td><td valign=top><b>Pan</b><br>North-South<br>East-West<br><br><b>Zoom</b><br>In<br>OUT</td></tr><tr><td><img src='Nav_2.jpg'></td><td><b>Zoom</b> to Area<br>Shift + drag mouse<br><b>Pan</b><br>Drag with mouse</td></tr><tr><td colspan=2>Tool active when on light-blue background</td></tr><tr><td colspan=2>Default: <br><B>Pan</b> by dragging with mouse<br><b>Zoom In</b>: Double-click on map</td></tr></table></center><br>"
}
else if(Q1_1==2)
{
Q11_Answer.innerHTML= "<br>Click on <img src='img/layer-switcher-maximize.png'> at the right of the map and select/deselect layer(s).<br>"
}
else if(Q1_1==3)
{
Q11_Answer.innerHTML= "<br>Feature digitizing is in freehand mode by default. In freehand mode, the mouse is treated as a pen. Drawing begins on mouse down, continues with every mouse move, and ends with mouse up.<br><br>To turn freehand mode off, hold down the shift key while digitizing. With freehand mode off, one vertex is added with each click and double-clicks finish drawing. Freehand mode can be toggled on and off at any time while drawing.<br>"
}
}
}


// -->
</script>
</head>
<body onload="init()" bgcolor=#ddf9f9>
<table border=1 cellpadding=5 width=99%>
<tr>
<td colspan=2><center>
<strong><font face="arial" size="5">Maroon Dam</font></strong></center>
</td>
</tr>
<tr>
<td width=70% height=370 valign=top>
<div id="map"></div>
</td>
<td valign=top>
<center>
<b>Help</b>
<SELECT Name="Q1_1" onchange="return q11_is(this)">
<OPTION Value=0>Select a Topic</OPTION>
<OPTION Value=1>Navigate</OPTION>
<OPTION Value=2>Layers</OPTION>
<OPTION Value=3>Draw</OPTION>
</select> <br>
</center>
<span id="Q11_Answer"><br><br></span></font>
<hr>
<center>
<b>Drawing Options</b></center>
<ul id="controlToggle">
<li>
<input type="radio" name="type" value="none" id="noneToggle"
onclick="toggleControl(this);" checked="checked" />

<label for="noneToggle">navigate</label>
</li>
<li>
<input type="radio" name="type" value="point" id="pointToggle" onclick="toggleControl(this);" />
<label for="pointToggle">draw point</label>
</li>
<li>
<input type="radio" name="type" value="line" id="lineToggle" onclick="toggleControl(this);" />
<label for="lineToggle">draw line</label>
</li>
<li>
<input type="radio" name="type" value="polygon" id="polygonToggle" onclick="toggleControl(this);" />
<label for="polygonToggle">draw polygon</label>
</li>
</ul>
<hr>
</td>
</tr>
<tr>
<td>
<b>
<img src="img/marker.png" width="15" alt="" border="0">
Research Projects&nbsp;&nbsp;&nbsp;
<img src="img/marker-blue.png" width="15" alt="" border="0">
Student Projects, Field Study Sites<br>
<img src="img/marker-gold.png" width="15" alt="" border="0">
Institutions&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<img src="img/marker-green.png" width="15" alt="" border="0">
Miscellanious
</b>
<hr>
<center>
<strong><font face="arial" color="#808080" size="-2">
School of Geography, Planning and Architecture, The University of Queensland
</font></strong>
</center>
</td>
<td>
<b>Commands:</b> Click to ...
<div
style="background-color:#e3fdf8" onclick="add_labels()">
<center>
<b>add Lables</b></center></div>
<div
style="background-color:#edfe9c" onclick="markers.setVisibility(true)">
<center>
<b>show Markers</b></center></div>
<div
style="background-color:#edfe9c" onclick="markers.setVisibility(false)">
<center>
<b>hide Markers</b></center></div>
</td>
</tr>
</table>
</body>
</html>

___________________________________________
 
Dr Gerd R Dowideit
School of Geography, Planning and Architecture
The University of Queensland
Chamberlain Building, Room 508
phone (07) 3365 3538 (work)
          (07) 3289 2325 (home)
 
________________________________________________
Dr Gerd R Dowideit
10 Atanie Court
Wights Mountain, QLD 4520
phone: (07) 3289 2325
 
 
________________________________________________
Dr Gerd R Dowideit
10 Atanie Court
Wights Mountain, QLD 4520
phone: (07) 3289 2325
 

_______________________________________________
Users mailing list
[hidden email]
http://openlayers.org/mailman/listinfo/users
Reply | Threaded
Open this post in threaded view
|

Re: FW: OpenLayers Beginners Questions

Christopher Schmidt-2
On Sun, Jun 17, 2007 at 02:11:40PM +1000, Gerd Dowideit wrote:

> Sorry, had problems with sending this. Gerd
>
>   _____  
>
> From: Gerd Dowideit [mailto:[hidden email]]
> Sent: Sunday, June 17, 2007 1:58 PM
> To: '[hidden email]'
> Subject: OpenLayers Beginners Questions
>
>
> Hi All,
> I am exploring OpenLayers since a few days and encounter typical beginners
> problems:
>
> 1.
>
> Trying to make use of "Class Documentation"
> (http://dev.openlayers.org/docs/overview-tree.html
> <blocked::http://dev.openlayers.org/docs/overview-tree.html> ): the docu is
> fine, but I do miss information about 'what each entry is good for' and
> brief examples about 'how to make use'. A list ordered by purpose of classes
> and functions would also be good. Is there such a list which I have not
> found yet?

Each item in the documentation *should* have a chunk of text explaining
what it's good for, like this:

 http://dev.openlayers.org/docs/OpenLayers/Layer/WMS.html#getFullRequestString

Some don't have one because they're seen as 'obvious'.

Others don't have one because they're sipmly not complete.

I'm assuming that this is what you're looking for: if so, then the
answer is probably "no, there is nothing like what you are looking for",
but http://openlayers.org/dev/examples/ is probably helpful, if you
haven't found that yet.

Note that there are also two significant changes coming in
documentation:
 * http://openlayers.org/pipermail/dev/2007-June/000851.html
   Creating examples TOC Sorted by title and by function/method type.
 * http://openlayers.org/pipermail/dev/2007-June/000854.html
   Improving the class reference documentation, which is currently
   segfaulting our documentation generator, resulting in hugely lacking
   documentation.

There are links from each of those emails with some documentation stuff
that will be more useful once it's complete, and I'm working hard on
getting it there.

> 2.
>
> Problem with "var pointLayer = new OpenLayers.Layer.Vector("Point
> Layer");" and similar (Line and Polygon): All draw controls seem to draw
> points and vertices south-east of where the mouse-click occurred by about
> 1/2 of the diameter of the drawn Point-Circle. That means all drawn features
> are miss-placed. Is this a bug or is it just that I do use the draw feature
> wrongly? Source attached below. The website is at this stage not public for
> administrative reasons; sorry.

Internet Explorer has problems with its 'box model': the 3px border
you're putting on your map is causing the browser to incorrectly report
your mouse position relative to the map. If you remove that border, this
will be fixed: you can instead create a slightly more complicated map
setup, with the map div inside another div which does have a border,
rather than putting it directly on a map.

Erik, this is a bug we might be able to work around, can you file a
ticket for 2.6 to look at this? Gerd, if you or anyone want to submit a
patch before that, then it should be able to make it into 2.5. The
function to look into is OpenLayers.Events.getMousePosition().

Regards,
--
Christopher Schmidt
MetaCarta
_______________________________________________
Users mailing list
[hidden email]
http://openlayers.org/mailman/listinfo/users
Reply | Threaded
Open this post in threaded view
|

Re: FW: OpenLayers Beginners Questions

Matthew D.Hancher
On Jun 17, 2007, at 5:04 AM, Christopher Schmidt wrote:

>> 2.
>>
>> Problem with "var pointLayer = new OpenLayers.Layer.Vector("Point
>> Layer");" and similar (Line and Polygon): All draw controls seem  
>> to draw
>> points and vertices south-east of where the mouse-click occurred  
>> by about
>> 1/2 of the diameter of the drawn Point-Circle. That means all  
>> drawn features
>> are miss-placed. Is this a bug or is it just that I do use the  
>> draw feature
>> wrongly? Source attached below. The website is at this stage not  
>> public for
>> administrative reasons; sorry.
>
> Internet Explorer has problems with its 'box model': the 3px border
> you're putting on your map is causing the browser to incorrectly  
> report
> your mouse position relative to the map. If you remove that border,  
> this
> will be fixed: you can instead create a slightly more complicated map
> setup, with the map div inside another div which does have a border,
> rather than putting it directly on a map.
>
> Erik, this is a bug we might be able to work around, can you file a
> ticket for 2.6 to look at this? Gerd, if you or anyone want to  
> submit a
> patch before that, then it should be able to make it into 2.5. The
> function to look into is OpenLayers.Events.getMousePosition().

For what it's worth, I've encountered a similar issue using Firefox  
under
certain specific situations.  For example, again modifying the
editingtoolbar.html example, try this:

     <table style="position:absolute; margin:20px"><tr><td> <div  
id="map"></div> </td></tr></table>

In this case getMousePosition() appears not to properly translate  
from client
coordinates to map-local coordinates, with an offset equal to the  
20px margin.
The problem goes away if you use padding instead of margin, if you  
make the
table non-absolute, if you use a div instead of a table, or if you  
use WebKit
instead of Firefox.  So this was easy enough for me to work around on  
my own,
but I thought if anybody starts looking at adding workarounds to  
getMousePosition()
they might want to know about it.

Matt

Matthew D. Hancher
Intelligent Systems Division
NASA Ames Research Center
Official: [hidden email]
Personal: [hidden email]



_______________________________________________
Users mailing list
[hidden email]
http://openlayers.org/mailman/listinfo/users
Reply | Threaded
Open this post in threaded view
|

Re: FW: OpenLayers Beginners Questions

Erik Uzureau-3
Made ticket:
http://trac.openlayers.org/ticket/817

On 6/17/07, Matt Hancher <[hidden email]> wrote:

> On Jun 17, 2007, at 5:04 AM, Christopher Schmidt wrote:
>
> >> 2.
> >>
> >>      Problem with "var pointLayer = new OpenLayers.Layer.Vector("Point
> >> Layer");" and similar (Line and Polygon): All draw controls seem
> >> to draw
> >> points and vertices south-east of where the mouse-click occurred
> >> by about
> >> 1/2 of the diameter of the drawn Point-Circle. That means all
> >> drawn features
> >> are miss-placed. Is this a bug or is it just that I do use the
> >> draw feature
> >> wrongly? Source attached below. The website is at this stage not
> >> public for
> >> administrative reasons; sorry.
> >
> > Internet Explorer has problems with its 'box model': the 3px border
> > you're putting on your map is causing the browser to incorrectly
> > report
> > your mouse position relative to the map. If you remove that border,
> > this
> > will be fixed: you can instead create a slightly more complicated map
> > setup, with the map div inside another div which does have a border,
> > rather than putting it directly on a map.
> >
> > Erik, this is a bug we might be able to work around, can you file a
> > ticket for 2.6 to look at this? Gerd, if you or anyone want to
> > submit a
> > patch before that, then it should be able to make it into 2.5. The
> > function to look into is OpenLayers.Events.getMousePosition().
>
> For what it's worth, I've encountered a similar issue using Firefox
> under
> certain specific situations.  For example, again modifying the
> editingtoolbar.html example, try this:
>
>      <table style="position:absolute; margin:20px"><tr><td> <div
> id="map"></div> </td></tr></table>
>
> In this case getMousePosition() appears not to properly translate
> from client
> coordinates to map-local coordinates, with an offset equal to the
> 20px margin.
> The problem goes away if you use padding instead of margin, if you
> make the
> table non-absolute, if you use a div instead of a table, or if you
> use WebKit
> instead of Firefox.  So this was easy enough for me to work around on
> my own,
> but I thought if anybody starts looking at adding workarounds to
> getMousePosition()
> they might want to know about it.
>
> Matt
>
> Matthew D. Hancher
> Intelligent Systems Division
> NASA Ames Research Center
> Official: [hidden email]
> Personal: [hidden email]
>
>
>
> _______________________________________________
> Users mailing list
> [hidden email]
> http://openlayers.org/mailman/listinfo/users
>
_______________________________________________
Users mailing list
[hidden email]
http://openlayers.org/mailman/listinfo/users