cmotell (5) [Avatar] Offline
#1
Listing 11.6 doesn't work for me at first with either Internet Explorer 7.x or Firefox 3.5.9.

First what didnt' work:
<body>
<h1>Open Street example</h1>
<div style="width:100%; height:100%" style="border: 2px solid red" id="map"></div>
<script type="text/javascript" defer="true">
init();
</script>
</body>

SO this worked fine when I switched to specify absolute widths!

Now what did work:

<div style="width:900px; height:900px" style="border: 2px solid red" id="map"></div>
<script type="text/javascript" defer="true">
init();
</script>
cmotell (5) [Avatar] Offline
#2
Re: Chapter 11 Listing 11.6 Problem using percent for width versus px?
Oops,

by including div tag could see my own post.

Listing 11.6 only works with using px for div width and height versus percentage.

That is, used:

<... style="width:900px; height:900px" style="border: 2px solid red" id="map"></...>
<script type="text/javascript" defer="true">
init();
</script>

NOTE: Replace div for ... Took out div because it formatted my post.
regina.leo (265) [Avatar] Offline
#3
Re: Chapter 11 Listing 11.6 Problem using percent for width versus px?
Craig,

Strange. The code we have in that example should be exactly what is shown here

http://www.postgis.us/demos/chapter_11/osm_newengland1.htm

(I did a quick scan and it looks the same, except the zoom is different than what we have in the link above).

I see the above in FF 3.5 and IE 8. Does the above link work for you?

Thanks,
Regina
cmotell (5) [Avatar] Offline
#4
Re: Chapter 11 Listing 11.6 Problem using percent for width versus px?
Regina:

I clicked on your page and it worked fine. So I cut and pasted your code into
mind page (only difference is I'm using a difference version browser and I'm
pointing to my local install (see below):

<title>Open Street Example</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="/geoserver/data/www/OpenLayers-2.9.1/theme/default/style.css" type="text/css" />
<script type="text/javascript" src="/geoserver/data/www/OpenLayers-2.9.1/OpenLayers.js"></script>
<script src="http://www.openstreetmap.org/openlayers/OpenStreetMap.js" ></script>
<script type="text/javascript">

var lat=20.66596;
var lon=103.13868;
var zoom=5;
var map; //complex object of type OpenLayers.Map
//Initialise the 'map' object
function init() {
etc, cut and pasted from your link.


Your link works fine. But I get no image unless I switch from width to pixels.
I'll explore more and let you know if I resolve.

One question, probably should put in another post:

projection: new OpenLayers.Projection("EPSG:900913"),
displayProjection: new OpenLayers.Projection("EPSG:4326")

DO you do the above because the data is in the EPSG:900913 projection?
Why do this remapping?

thanks Craig
regina.leo (265) [Avatar] Offline
#5
Re: Chapter 11 Listing 11.6 Problem using percent for width versus px?
The display projection is what projection the coordinates are displayed in to the user as they move their mouse -- that little text that shows the long lat coordinates in the right corner of the map as you move your mouse.

No one could make sense of the google mercator projection so is only useful for actually displaying the data. OpenStreetMap tiles are in EPSG:900913 (more or less google mercator/web mercator projection) which is the reason for the 900913