This is the P2PU Archive. If you want the current site, go to www.p2pu.org!

Online Maps with OpenLayers

My recent threads

You haven't posted any discussions yet.

Recently updated threads

trouble getting examples to work

Go back to: General discussion

What do I need to do to get the example in the walkthrough to work from my laptop (Ubuntu/LAMP)?

How do I get this example, http://workshops.opengeo.org/openlayers-intro/basics/map.html to work on jsFiddle?

-introvert

Nick Doiron's picture
Nick Doiron
Thu, 2011-02-10 16:52

I just got the OpenGeo example working this morning. The original setup is zoomed too far out, I think

http://jsfiddle.net/UAxun/66/

Now, getting the walkthrough example working on your own server:

First, make sure you are importing the OpenLayers library in the section of your page, before any other JavaScript. This would be http://openlayers.org/api/OpenLayers.js

Put the map-creation JavaScript into a function, such as

<script type="text/javascript">
function makeMap(){
map = new OpenLayers.Map({div:"map-div"});
...
}</script>

Have that function run when all scripts have loaded, by changing <body> to <body onload="makeMap()">

intro vert's picture
intro vert
Sat, 2011-02-12 13:01

Yes, I think I have imported the library. I tried your suggestion and played around with it but still nothing.

intro vert's picture
intro vert
Sun, 2011-02-13 08:09

Ah, I got it.

tyrock- -ford's picture
tyrock- -ford
Thu, 2011-02-10 22:51

If I could piggy back off of your question on examples not working. I got the OpenGeo example up and running http://jsfiddle.net/tyrockford/MLJdJ/12/ but am having problems with the Base layer switching http://workshops.opengeo.org/openlayers-intro/layers/proprietary.html . The OSM layer is fine but I can't seem to get the Bing layer working. The error message tells me that the library script is not included correctly. I checked the Bing Maps API http://msdn.microsoft.com/en-us/library/gg427624.aspx and the code that they use for javascript is not working. My guess is that I am not adding it correctly in the resources.
Any ideas on where I am going wrong?
Thanks.

Nick Doiron's picture
Nick Doiron
Fri, 2011-02-11 00:51

The Bing / Virtual Earth example at that link is outdated. The new version of the Bing layer is described here:

http://openlayers.org/blog/2010/12/18/bing-tiles-for-openlayers/

You may prefer the older version because that doesn't require an API key. Make sure you added the script listed in step 2 on your OSGEO link. On jsFiddle, you add it using the Resources panel on the left side.