Trouble with Web Map Builder?

By , 16, March, 2011 12:07 pm
GeoDoctor

The GeoDoctor

In this post I’m going to focus on a particular developer issue around the use of our Web Map Builder. Questions have arisen around what you do with the code you get when you press the ‘Collect code’ button in ‘Step 4 – Generate and save code’. You are actually given a fully formed HTML document.

This is fantastic if all you want is a blank page with a map in it.

For that all I would need to do is:

1. Select all the code

2. Copy the code into a text editor, such as Notepad.

3. Save it as <name>.html, such as mymap.html.

4. Put it on my webserver

You will hopefully have something that looks like this: Continue reading 'Trouble with Web Map Builder?'»

Five geo-predictions for 2011

By , 18, January, 2011 1:12 pm

The GeoDoctor turns his mind to the the coming year

The GeoDoctor turns his mind to the year ahead.

Traditionally, the New Year is a time to reflect on what has passed and what’s on the horizon. So, with the help of my colleagues, I thought this was a good time to take a look at some possible trends in the geospatial industry, and to even to make a few predictions for the year ahead.

I thought I would stay clear of the areas that other bloggers have covered so well, and try and give a little more left-field perspective.

1. A significant open data application.

We’ve seen an increasing amount of open data released in recent years and there has been a huge amount written about it and how it could be used. There have been a number of implementations (dare I mention the ASBOrometer?!) but what I haven’t seen, and please correct me if I’m wrong, is a huge consumer app, or killer app which is commercial and actually makes money.

I think 2011 could be the year it happens.

2. More online geospatial service providers.

I think this area will inevitably grow. Last year we saw the launch of online based GI services from both the traditional vendors as well as new entrants to the market, such as GIS Cloud. Why do I find this an area of interest? I think it’s because the barriers to entry are now so much lower.

Most GI functionality is now available as open source, so hosting and delivering online is considerably cheaper and faster to implement, thanks to cloud infrastructure. Continue reading 'Five geo-predictions for 2011'»

The GeoClinic: Updating OS OpenSpace

By , 29, September, 2010 8:17 am

the GeoDoctor in pensive mood.

the GeoDoctor in pensive mood.

Over the last two weeks there have been a couple of important updates to OS OpenSpace so I thought during this GeoClinic, I would take a look at what’s new and what it means for our developers and users.

OS Vector Map District arrives

Since OS VectorMap District is available as a download from OS OpenData, it isn’t surprising that it’s now found its way into OS OpenSpace.

On the OS OpenSpace blog we announced that VMD is now available in Web Map Builder, but the more eager of you may want to use it in your OS OpenSpace application. Anybody who’s looked at VMD in Web Map Builder will see that it sits nicely between the 1:50 000 views and OS Street View.

If you are an OS OpenSpace Pro user, the great news is that you can now use

product codes to specify which products you want in your map. There
is a nice comprehensive review on the wiki.

If you are a regular OS OpenSpace user, product codes are not currently available, but the more astute of you may have looked at the code generated by Web Map Builder and seen how VMD is accessed by declaring resolutions, rather than product codes.

To understand a little about resolutions, check out our FAQs.

Before going any further, I have to point out that at some point in the future, product codes will be introduced to the free OS OpenSpace service, which will render the resolution declaration method invalid and your site may no longer work!

So with that in mind, if you wish to include VMD in your free OS OpenSpace site, you can use the following code snippet:

var options = {resolutions: [2500, 1000, 500, 200, 100, 50, 25, 10, 5, 4, 2.5, 2, 1]};

osMap = new OpenSpace.Map(‘map’, options);

Here is a fully worked example – zoom through the layers to reach VMD:

OS OpenSpace 2.8

For all of you developers who wish to take advantage to the improvements made in OpenLayers 2.8, OS OpenSpace has now been updated to make use of that library.

Of particular significance for many was the issue around Internet Explorer 8 compatibility. So this is great news!

Increase in tile limits for free OS OpenSpace

Daily tile limits have now been raised to 65,000 so your project can now use even more mapping. Geo-tastic.

Updated CKEditor

Web Map Builder uses CKEditor so users adding marker content have a nice WYSIWYG Text and HTML Editor. There were a couple of bugs in the previous version so the upgrade has resolved these and should be a better experience for many of our users.

Well that’s all for now. In addition to the headline updates above, there have been numerous bug fixes as we continue to improve OS OpenSpace.

Please let me know if you have any questions around these items, or anything you would like me to cover in future Clinics.

The GeoDoctor is here to serve!

Happy mapping!

Top 5 OS OpenSpace questions

By , 11, August, 2010 4:06 pm

In this GeoClinic I thought I would take a look at, and answer, some of the top 5 questions our wonderful Customer Service Center receive. So, thanks to Marie and Kate in the team for helping put these questions together.

GeoDoctor

1. I’ve forgotten (or how do I reset) my OS OpenSpace password?

This can all be easily handled online.
- Go to the OS OpenSpace Forum
- Click on Login (top right-hand box)
- Click on “I forgot my password”
- Follow the instructions

2. My API key is registered to the wrong URL or I wish to add another UR to my API key

Registering a URL in OS OpenSpace links it to the API key sent to you. However, it is often the case that you wish to host the application at another URL or even host your application on two URLs. If this is the case, then simply contact us and we’ll be able to help you with the change you wish to make.

Please note that the tile and lookup limits are assigned to the API key, so if you are using multiple URLs against one API key you’ll be spreading the limits amongst all those URLs.

OS OpenSpace

3. I would like to develop my application before deploying it to the registered URL, will my API key still work?

Your API key will work against your registered URL and localhost, for example http://localhost/myapp.html. This means you can install a webserver on your development/test environment and your application will work perfectly well if you can access it using localhost. Just as it will do when deployed at your registered URL.

4. I get an “HTTP Referrer not Valid” message

This is typically caused by there being a mismatch between your API key and the URL you have registered. Please check that the API key your have entered is the one the registration process sent to you. Otherwise, please get in touch so we can check that the API key and URL you are using are correctly registered. Please include your API key and the URL you are using in any correspondance.

5. I’m interested in upgrading to OS OpenSpace Pro. Please tell me more about it and how I can sign up.

The following link has details about OS OpenSpace Pro. Currently, Pro enhances OS OpenSpace by offering no data volume limits with our charged utility pricing model. If you’re interested in using OS OpenSpace Pro, just let us know.

Ask the GeoDoctor

By , 21, July, 2010 2:11 pm

The GeoDoctorDeveloping with OS OpenSpace on multiple URLs

This question was recently asked by @skipchris. As anyone who has signed up to develop with OS OpenSpace has discovered, the API required the use of an API key. This key is tied to the URL the developer registered. This means that if I registered my site URL in OS OpenSpace as www.mydomain.com, my application would only work when hosted on www.mydomain.com.

However, the API key allows you to develop on localhost as well. What this means is that during development I can run a webserver on my local computer and assuming that I can run my application as http://localhost, my API key will be valid, as well as on the registered domain.

For example, I could develop an application in Web Map Builder, save it to a file called “myapp.html”. Assuming I have a local webserver, this application would work on both localhost and on the domain I registered:

http://localhost/myapp.html

and

http://<my_OS_OpenSPace_Registered_Domain>/myapp.html

So what happens if I wish to change my registered domain?

Simply drop the OS OpenSpace team an email detailing the URL you wish to change to, along with your API key and this can be sorted for you.

Adding Markers to an OS OpenSpace map from a database

Using Web Map Builder for OS OpenSpace is great way to get your first map on your site. However, many users wish to go further than that and place items on OS OpenSpace from a file or database.

Here I’ll cover how to draw markers from a simple database.

This clinic will go through how I produced this map, for which the code can be found here.

Firstly, there are a couple of points to note:

  • I’ll only be displaying markers, no reason why this couldn’t be extended to other feature types.
  • My database has only a few points. If you have a very large number of features (over a couple of hundred), you may wish to try a different strategy. Why? Basically, with the method illustrated below, all the markers are loaded into the browser and after a couple of hundred the browser becomes sluggish. I’ll cover what to do with many thousands of markers/points in a later clinic.
  • We’ll be using PHP to retrieve the database values. PHP is a server-side scripting language, ideal for what we want to do.
  • The database does not use spatial feature types, just simple X and Y columns.
  • The example assumes that the coordinates stored are in the OSGB coordinate system.

So, before I can display anything I’ll need:

  • A database with some data in it. Today my database of choice is MySQL.
  • An OS OpenSpace map to display my markers on.

First, the database. My example is very simple. I have a single table with the following columns: X ,Y, text and ID

It has some simple data in it:

TableThe critical steps I used to make markers from this database on my OS OpenSpace map are as follows:

1. Open a connection to the database:

$user_name = “*******”;

$password = “*******”;

$database = “*******”;

$server = “*******.mysql”;

$db_handle = mysql_connect($server, $user_name, $password);

$db_found = mysql_select_db($database, $db_handle);

2. Select all the records in the bee_marker table:

$SQL = “SELECT * FROM bee_marker order by id;”;

3. For every row returned from the query, construct the usual create Marker function using the X and Y coordinates for the position and the text for the information bubble:

while($row = mysql_fetch_array($result)){

$x = $row['X'];

$y = $row['Y'];

$text = $row['text'];

$id = $row['id'];

echo “pos = new OpenSpace.MapPoint(” . $x . “,” . $y .”);n”;

$textdec = html_entity_decode($text);

echo “var beeicon = new OpenSpace.Icon(‘bee-marker.png’, size, offset, null, infoWindowAnchor);n”;

echo “content = ‘” . $textdec . “<br><a href=”mailto:ian.holt@ordnancesurvey.co.uk?subject=BeeGardens%20Moderator%20Report

%20for%20marker%20″ . $id . “.”>Report Problem</a>’;n”;

echo “osMap.createMarker(pos, beeicon, content, new OpenLayers.Size(500, 200));n”;

}

Next time, if you’re interested, I could extend this example with code on how you could place their own markers and information on the map.

The GeoClinic

By , 30, June, 2010 9:01 am
The GeoDoctor prepares his diagnosis

The GeoDoctor prepares his diagnosis

We had a question in my last Clinic from Ben Ratcliffe. He asked:  ”I am trying to upload OS OpenData Streetview to geoserver either as a geotiff or a linked shp file to use as an internal WMS server. I have had no end of problems trying to convert the tiff + world file to geotiff using various tools such as FWtools, lizardtech geoviewer, listgeo and a few more that I have found. I have even tried using OSGB web map tools, this has some success but when I upload to geoserver, it loses the connection to the tiff files and then shows blank squares.”

Obviously it is sometimes a little bit difficult to diagnose a problem remotely, but what I will go through is a remedy which we use and hopefully will solve your issue as well.

I’ll present this as a series of steps, this is for GeoServer 2.0.2, so other versions may vary:

1) Download your OS Street View tiles from the OS OpenData site

2) Put all the .tif and .tfw files together in a new folder in the GeoServer data directory.

3) Add a new store in GeoServer, specify you’ll be using ImageMosaic and include the URL to the appropriate folder.

4) Publish the layer in GeoServer. This creates a number of files in the specified data directory, most notably one named <folderhame>.prj, which defaults to a WGS84 projection.

5) Delete the layer (not the store) in GeoServer

6) Replace the content of the <folderhame>.prj with details for British National Grid in this link

7) Add a layer in GeoServer and you should see the Native SRS set to 27700

The image tiles should now be served up correctly by GeoServer.

Thanks goes out to Tim Martin in answering this question.

Can I mix other mapping APIs with OS OpenSpace?

There are two aspects to this question. Some of you may have seen Tim Martin at AGI 2009 in a joint presentation with Bing. He demonstrated how you can pull in Microsoft Bing Maps into OS OpenSpace. The first point to consider is whether it is permissible between the APIs Terms of Use.

Assuming it is, there is then a significant technical aspect that you have to take into consideration. OS OpenSpace (based on OSGB) and other mapping APIs vary in their projections. That is, it is not possible to overlay the two layers without re-projecting one or the other, often resulting in something which doesn’t look very pretty!

The example that Tim used at AGI 2009 was to switch between the two mapping APIs, they were never displayed together. Of course, this also underlines a significant point that any data that you display on OS OpenSpace must be displayed using the OSGB projection.

How do I add boundaries in OS OpenSpace?

One of the coolest things you can do with OS OpenSpace is to add boundary data to your mash-up. By including boundaries you can display a whole range of different data in a way that is easy interpret and compare. OS OpenSpace includes a boundary lookup service, more details can be found here.

Using boundaries with OS OpenSpace

Using boundaries with OS OpenSpace

These can be used within OS OpenSpace to show customised and styled boundaries in your map, as well as design thematic maps using your own or third party data.

Functions are available within OS OpenSpace to make the inclusion of boundaries as straight forward as possible. The best way to understand how boundaries can be included and used in your maps is through the examples on the OS OpenSpace site:

Creating thematic boundaries and

Adding a single boundary layer with default styling

Feel free to look at our other examples to see other innovative ways of using boundaries.

Welcome to the GeoClinic

By , 9, June, 2010 11:20 am
Ian Holt is the Geo Doctor

Ian Holt is the GeoDoctor

Welcome to the GeoClinic, my new regular surgery where, as the resident GeoDoctor, I will endeavour to diagnose your Geographic Information related aches, pains and maladies.

So, if GI is giving you a headache, if your TOIDs are causing irritation or if your web map could use a physical, then tell me here on the blog or tweet me or Ordnance Survey, and I will prescribe the solution.

The Doctor is in…

How do I get the Web-Map Builder code into my website also how do I save the code?

Web-Map Builder is an excellent free and easy to use tool for making an OS OpenSpace map. A question I’m often asked is “I’ve made a very nice map, now how do I get it on my web page?”.

First of all you’ll notice that Step 4 allows you to click on a “Collect Code” button. This presents you with the code of a complete web page. You can copy this code into a blank text document, save it with extension .html and upload this directly to your web host and by navigating to that uploaded document in your browser.

However, many people ask “what happens if I already have a web page and wish to put this map inside it?”. Good question.

There are 2 main ways of doing this. I’ll take you through the way I find to be the easiest, but if you have any problems just let me know:

Reference your new map inside an iFrame (The easy way)

First, take the Web-Map Builder code, save it in a blank document as a .html file. Upload the file to your web host.

Now in your existing web page create an iFrame of the same dimensions as your map and put a link to your uploaded html document, as shown by the example below:

  • I copied the web map builder code into notepad.
  • Saved it as examplemap.html.
  • Uploaded it to my web host.
  • In the page I wanted to display the map, at the appropriate point I inserted these lines of code:

<iframe src=”http://www.ianholt.me.uk/examplemap.html” width=”450″ height=”350″ frameborder=””0″ scrolling=””auto”” name=

“”oswebmapframe””></iframe>

Now my map appears nicely in the existing web page, like this!

Can I use GPX files within OS OpenSpace?

What will the GeoDoctor prescribe?

What will the GeoDoctor prescribe?

GPX, a format commonly exported from a GPS device and is one of the formats that OS OpenSpace supports through the Open Layers library. A point to note is that browser security will stop you directly using a GPX from a local file.

What you have to do is upload the GPX file to your web host, like you would a photo (you could offer a simple form to the user to enable them to do this).

Once the file is on your web host, you can then make use of it within your OS OpenSpace application, quite simply by calling the function to add a new GML layer and specifying the format as GPX:

// Add the Layer with GPX Track

var lgpx = new OpenLayers.Layer.GML(“MB Bruderholz”, “mb_bruderholz.GPX”, {

format: OpenLayers.Format.GPX,

style: {strokeColor: “green”, strokeWidth: 5, strokeOpacity: 0.5},

projection: new OpenLayers.Projection(“EPSG:4326″)

});

map.addLayer(lgpx);

You can view the full example here on the OpenStreetMap wiki.

Why doesn’t OS OpenSpace work well with Internet Explorer 8?

Unfortunately, this is an issue which has cropped up. The good news is that in the next OS OpenSpace release we will be upgrading to OpenLayers 2.8 which will solve compatibility issues with IE8. In the meantime, or if you are using a previous version, there is a very easy way to handle this, by including this line of code in the HTML document header:

<meta http-equiv=”X-UA-Compatible” content=”IE=EmulateIE7″/>

I hope my answers are useful, but if anyone has any other questions about using GI, either on the web or in a traditional GIS system, then just let me know and I’ll do my best to answer them in my next clinic.

Until next time!

Panorama Theme by Themocracy

© 2011-2012 Ordnance Survey Crown copyright