Creating a transparent overlay map with mapbox-ios-sdk

For this blog post i have managed to capture on of EDINA’s mobile developers.  Their guest article will describe how to create transparent overlays for mobiles using mapbox-ios-sdk.

I am working on a historic map overlay, where the user can adjust the transparency of the historic map. The user can then see the how the land use has changed over time by using the slider.

opacity-map-overlay

I am going to use the map-box fork of route me. Looks like a good bug fixed version of Route-me and map-box do seem to have great some great products.

Unfortunately it doesn’t have an have an API to dynamically change the opacity of a tile source out the box. So I added it.

Its pretty easy to add. Each tileSource has a RMMapTileLayerView container when added to the map. Within that can manipulate the CALayer.opacity to get the desired effect.

I added a fork to github for testing

https://github.com/murrayk/mapbox-ios-sdk/

And example of use – the code is in github. Do a ‘git clone –recursive’ to install the submodules.

https://github.com/murrayk/mapbox-overlay-opacity-example

And example of use. In the  main view controller.

- (void)viewDidLoad
{
    [super viewDidLoad];
        // Do any additional setup after loading the view, typically from a nib.
    RMOpenStreetMapSource * openStreetMap = [[RMOpenStreetMapSource alloc] init];
    RMGenericMapSource * weatherMap = [[RMGenericMapSource alloc] initWithHost:@"tile.openweathermap.org/map/clouds" tileCacheKey:@"cloudCover" minZoom:0 maxZoom:18];

    self.mapView.tileSource = openStreetMap;

    [self.mapView addTileSource:weatherMap];

    self.overlay = weatherMap;
    // rough bb W = -30.0 degrees; E = 50.0 degrees; S = +35.0 degrees; N = +70.0 degrees
    NSLog(@"zooming to europe");
    CLLocationCoordinate2D northEastEurope = CLLocationCoordinate2DMake(70,-30);
    CLLocationCoordinate2D southWestEurope= CLLocationCoordinate2DMake(35,50);
    [self.mapView zoomWithLatitudeLongitudeBoundsSouthWest:southWestEurope northEast:northEastEurope animated:YES];

    [self.mapView setOpacity:0.5 forTileSource: self.overlay];

}

//hook up a slider to manipulate the opacity.  

- (IBAction)changeOverlayOpacity:(UISlider *)sender {

    NSLog(@"Slider value changed %f", sender.value );
    [self.mapView setOpacity:sender.value forTileSource: self.overlay];
}
If you found this blog useful, you might want to look through the archived articles on EDINA’s developers Geo-Mobile blog

 

FOSS4G – a developers review – part4

The 4th and final EDINA developers eye view of FOSS4G 2013.  This one is from Tim Urwin who is the Digimap Service Manager.  Tim has been working at EDINA pretty much from the start of it’s internet mapping adventure and has seen software and toolkits come and go.

Who are you?
My name is Tim and I’m the senior GI Engineer at EDINA in charge of the Data Team and I’m the Operation Service Manager for Digimap. My interest in attending FOSS4G centred around three key components of the Digimap Service: WMS Servers, WMTS options and Database, although I delegated most of the latter to Mike due timetable clashes.

What did you hope to get out of the event?
My aim was to catch up on the latest state and future options of current software used by EDINA services and to find out more about the various open source WMTS options available.

Top 3 things? (Ed – no trains Tim!)

 

  • Chris Tucker’s MapStory keynote was inspirational and well-presented and it is certainly a site I’ll be tracking to see where it heads.
  • Ben Henning’s key note on think before you act for cartography was quite thought provoking.
  • Paul Ramsey’s PostGIS Frenzy talk was as funny as it was informative, and I only caught the re-run. Lots of good information combined with useful tips. (Ed- Paul’s a star, there wasn’t enough room for everyone first time round so he kindly offered to repeat the talk)
  • Honourable mention must go to the Festival of the Spoke Nerd – very, very funny
What will you investigate further?
MapCache and MapProxy WMTS software to replace our existing tile caching option and catch up with all the presentations I couldn’t attend due to timetable clashes. (Ed – remember that all the talks (hopefully) will be available on the FOSS4G YouTube channel when we get them sorted and uploaded)
One closing thought is that it was heartening to see that despite all the professional headaches that Digimap has caused me over the years that our approach to and delivery of the service has been validated as several leading data supply agencies have very similar service architectures. Built with Open Source software at the core, although there with some proprietary components for certain tasks. The primary differences being in WMS and caching software options, although they’ll be closer aligned once we upgrade to a more modern tile caching platform. Now only if we could also have their hardware – they have significantly larger number of servers :)

Oh and as I wasn’t allowed this in my Top 3 – seeing 45108 running again after 16 years of hard work by its custodian group.

AGIScotland 2013 – New directions in Geo

The 2013 AGI Scotland event marked a slight change in direction for the AGI, this being the first “showcase” event that they have run. 6 showcase events and the annual GeoCommunity event are scheduled across the year.

It was fitting that the first plenary speaker was from the Scottish Government. Mike Neilson is the Director of Digital and represents the top end of the digital restructuring that has occurred in the Scottish Government. Mike reinforced the importance of digital in governing a country and that there was a push to make more public services available on line. This would encourage the public to get online, but Mike was acutely aware that there was a danger that moving services online would exclude those who could not get online, perhaps due to financial constrains. Improving digital connectivity was important as Scotland, especially Glasgow, currently lags behind the UK average which impacts on the social and economic development of the Country.

At a recent meeting of the Spatial Information Board, 6 priorities were agreed and these will form the focus of activities in the immediate future. These are:

  1. effective use of spatial data thru inspire
  2. data sharing and collaborative procurement
  3. build GIS capabilities capacity
  4. embed spatial data within broader data agenda
  5. promote awareness of benefits of wider use of spatial
  6. mechanism for hosting spatial data

The restructuring of digital data teams in the government seems to make sense and looks to provide sensible, hierarchical structure. However, the Scottish Government are looking for feedback and input from the GI community on what they see as being important and where they think digital data is going.  To provide feedback you can contact shonna or follow them on Twitter @digitalscots

The second plenary speaker was Anne Kemp, Atkins. Anne pointed to the changing role of the GI professional and urged us to step out of our insular groups and comfort zones and to interact with other groups who use spatial data. Anne strongly believes that Building Information Models (BIMs) are the future for many aspects of GIS. BIMs focus on the lifecycle of anything in the built environment, from planning to operational management. Calculations suggest that effective use of BIMs can save 20% in the cost of construction and operation of new infrastructure.  The use of BIMs has been mandated by the government for England and organisations, such as the Environment Agency and Highways Agency, are currently aligning themselves to meet the 2016 target. Interestingly the Scottish Government does not have a similar mandate and seems to have no plan to do so. This raises interesting questions. Many large engineering companies and consultancies are GB wide organisations and tend to operate to organisation wide best practices, of which BIM is almost certainly going to be. Will much of BIMs seems to just represent industry best practice, mandate from central government which then filters down through local government would ensure best practice and potentially interoperability across infrastructure. Certainly the feeling from the floor was that if BIM was being adopted wholesale south of the border and that BIM management was seen as an exportable skill-set, it might be sensible to mandate it in Scotland as well. (cough trams, cough cough Scottish parliament, cough).

Next up was a double act from SEPA’s Dave Watson and Duncan Taylor who introduced Scotland’s Environment Web (http://www.environment.scotland.gov.uk/).  Scotland’s Environment Web (SEWeb) brings together information on Scotland’s environment. It merges environmental data, information and reports, from known and trusted sources, so they can all be viewed in one place. SEWeb links to 30 WMS which are organized in themed groups. Dave and Duncan outlined the pro’s and con’s of this approach.

Good:

  • Each organization is responsible for their own data
  • Reduces development time and maintenance
  • Maintains 1 version of the truth
  • No singl point of failure

Bad:

  • Many points of failure which it is hard to track and sometimes confusing for the user to know who to contact if there are problems

Ugly:

  • No standard look and feel to symbology and styles
  • Issues with data scales.

The current work represents Phase One. Phase Two will allow users to download data and there is a business case to support forestry assessments.  There is a longterm aim to add WFS capabilities to SEWeb.

One of the sites that feeds data into SEWeb is Scotland’s Soils, run by the James Hutton Institute.  The soil map is based on the 1984 1:250,000 mapping and has 580 different mapping units although the web map uses a simplified unit scheme. You can also access the data through an iPhone app which gives you access to the soil structure at over 600 points across Scotland.

It is great to see this data being made available, but I can see the “ugly” issues mentioned by Dave and Duncan.  Just move from Scotland’s Environment to Scotland’s Soils and the maps are very different. From a usability side of things the map controls are completely different.  We, as GIS professionals, have no problem knowing how to use either. They are intuitive to us, but we are experts. The average member of the public may well struggle. Imagine if they finally learn to use 1 map interface then find that the map on the other site is completely different. Not ideal. The solution would be to develop a consistent interface and share the code. However, this would mean that all partners would have to agree to use the same libraries to build their web maps.

Other highlights from the event included Astun Technologies Mike Saunt who talked about “Doing something with this Open Stuff”.  Mike showed how local government was making data available, and importantly, accessible. Councils could then share data feeds automatically therefore saving time and money. However, Mike highlighted some of the problems that arose when making data open with examples where url’s did not resolve because of typo’s. More worryingly was an organization that was promoting it’s WMS but was also serving a WFS. The organization was not promoting or linking to the WFS and Mike suggested that they may not be aware that they were serving the WFS.  The solution is to ensure you understand what you are making available and why. If you don’t have the skills in house then get someone in to ensure everything is set up correctly.  This is kind of what Astun do and using services like theirs is a cost effective way of working.

Another talk that really shone was Crispin Hoult from Link Node. Crispin introduced the concept of GIality which is the use of geospatial data in augmented reality. This makes a lot of sense. You have a location aware device with a host of sensors in it and can use this to visualize changes to a landscape while you are actually in that environment. This semi-immersive technology would certainly help the visualization of developments like windfarms or new housing estates and takes us beyond the “comfortable” use of overlays on paper maps.

The day finished up with Anne Kemp talking about the future of AGI Scotland and the strengthening community of GIS professionals in Scotland.  There was mention of the Chartered Geographer in GIS qualification but it was pointed out that to become chartered you had to join the Royal Geographic Society (RGS) which did not have a remit in Scotland. Anne noted this and said she would look into it.  She also mentioned other recognised professional qualifications such as the Royal Institute of Chartered Surveyors (RICS) who offer a GIS orientated qualification. Will be interesting to see how the CGeog GIS issue progresses this year.  It does seem the best suited but is not perfect if you are living and working in Scotland.

Geospatial API’s and other tools for developers

Since the release of Open data back in 2010, and through the rise of mobiles and the App, the use of spatial data by developers has increased significantly.  Spatial data is no longer the preserve of the geospatial scientists, it is used by mainstream developers who see the value of location. I this post we will look at some of the “free” data and tools that you can use.

Data

OpenstreamAPI:

The Digimap OpenStream service provides access to a Web Map Service (WMS) offering Ordnance Survey OpenData products, including GB Overview, Miniscale, 1:250000 Colour Raster, VectorMap District Raster and OS Streetview.

EDINA aims to provide the latest version of OS OpenData via the OpenStream service. Once registered, you can use the Digimap OpenStream API to do things like:

  • Mashups, combining OS Opendata with maps and data from other sources.
  • adding OS Opendata to Google Earth.
  • Embed maps in your website.
  • provide OS mapping in your own applications.
  • provide OS mapping in a Desktop GIS project.

Openstream viewed in Google Earth

If you want to find out how to use Openstream please check out the folowing useful links:

Advantages – Free. Easy to use and provides regularly updated OS mapping. Available in OSGB and WGS1984 projections
Disadvantages – Not as easy to use in WGS84 as google maps, no satellite imagery available through API.

Google

Most people will be familiar with Google maps, specially if they have a smart phone. What can you say. Global cover (almost) and improving all the time. Packed with detail in urban areas. I suppose the weakness is in rural areas where detail may be sparse. Google maps is enough for many applications but if you may not be as accurate as the data from a national mapping agency, such as the OS.
Google maps is generally available for free in most cases. You have to pay if you use lots of data or if you want the data behind a login.

OpenStreetMap

OpenStreetMap is global community mapping project that wants to make a freely available map of the World. 10 years ago this would have been a crazy idea but today it is almost a reality. It suffers in the same way as Google maps in that it is great in urban areas and less good in rural areas. But, if the detail is not there, just sign up to the cause and add the detail yourself. Your edits will then be available for your, and everyone else’s, map.

Bing

Bing have a mapping stack that you can access through an API in a similar way to Google. Bing was quick to offer a bird’s eye view option for its satellite data and also has OS 1:50 000 mapping available as well as offering detailed street mapping for London. It is worth looking at the data available through the Bing Maps API as it is different to that offered by Google and may better suit your needs.

British Geological Survey

The BGS offer a number of Web Mapping Services (WMS) for developers and GUS users. These include 1:50 000 scale mapping, 1:625 000 mapping (on and offshore), 1:625 000 Hydrogeology, Soil data and contaminated land data. Full information on the use of these datasets and the GetCapabilities statements needed to access them is provided on the BGS website.

API Services

An Application Programming Interface (API) is a protocol intended to be used as an interface by software components to communicate with each other. An API is a library that may include specifications for routines, data structures, object classes, and variables. Thee are a number of API’s that give developers to spatial data and tools to create interactive web maps.

Unlock Text

Unlock Text is a powerful geoparser that can search text hosted on the web in .txt or .html format for references to locations. These locations are then returned ready for use in your results page, web map or any other application.

Unlock

Unlock Text is a RESTful API, you can use it by first setting up a username and password using the POST operation. You can use the GET operation to find out information about this account such as the number of Text documents that have been parsed. POST and GET operations can be used to set up new documents to be parsed and to retrieve the urls of results pages created by the parser.

You will need to use cURL commands; or a REST Console or Client which are available as add-ons for Chrome and Firefox web browsers, to use Unlock Text.

Advantages: Free! There is not really anything else out there to compete with it, unless you pay!

Limitations: Not always a perfect set of results, but then no one else does it perfectly either.  Wikipedia currently blocks it!

Unlock Places

Unlock Places is a place search web service, its API helps developers to find locations for place names. You can also use it to convert postcodes into coordinates, look up electoral boundaries, and to find shapes that overlap or intersect one another.

Unlock Places can provide geographic information describing places – or other features – as points (latitude-longitude coordinates) or larger bounding boxes and more detailed shapes (where possible).

Unlock Places can be used in your web project, app or mobile information service to add a geospatial location on to users’ data.

Advantages: Free

Limitations: Some searches can be a bit slow

National Library of Scotland

NLS

The NLS has a fantastic api which offers access to Historic Maps of the UK. Thus service is great and the mapping is based on out-of-copyright Ordnance Survey maps, dating from the 1920s to the 1940s. Full details of how to implement the map on a webpage or on a mobile app are available on the NLS website.

Google

Google has a host of API’s that allow developers to tap into tools and content delivered by Google. On the maps side of things, there is:

  • Google Maps JavaScripts API v3 – It provides you with the framework to add a number of unique features and content to a Google Maps interface and embed Google Maps in your own web pages. Version 3 of this API is especially designed to be faster and more applicable to mobile devices, as well as traditional desktop browser applications. The API provides a number of utilities for manipulating maps (just like on the http://maps.google.com web page) and adding content to the map through a variety of services. The JavaScript Maps API V3 is a free service, available for any web site that is free to consumers.
  • Mobile API and SDK – Google offers an Google Maps for Android API and a Native iOS SDK for Apple.  Both will allow developers access to google map content and functions such as titl, 3D buildings and Streetview.
The Google maps api has a free use cap of 750k maps a month.  If you think you will exceed this, then you can buy capacity.

Advantages: Google is by far the most popular API for mapping. The public are generally aware of Google Maps and are familiar with both the controls and the content. Mobile Friendly.
Disadvantages: Just because it is the most popular doesn’t mean that it will suit your needs. In particular, the level of details is patchy and may not provide your users with the richness that they need.  For example, you wouldn’t head off into the hills with Google Maps as your main navigational aid. Not entirely free.

Bing Maps API

Bing Maps API offers developers access most of the mapping and satellite images that are available through their main map site.

Bing Maps API as it is different to that offered by Google and may better suit your needs. Did i mention that Bing also does directions? Well it does for car, walking and public transport. The Bing api is has a free option but this has a usage cap and remove the birds-eye view function.  Education/not for profit accounts are available and commercial organisations can sign up to a range of service packages.

Advantages: Alternative mapping stack to Google API and similar user experience. Imagery pretty new.
Disadvantages: User community not as large as Google’s, not free.

Here API

Not heard of Here Maps API? Well Nokia is behind the Here API and that is a good start. Long before Google got serious about delivering spatial data to mobile phones, Nokia were supplying their handsets with mapping pre-loaded. OviMaps, as they used to be known, were pretty good and Nokia have developed them into the Here API service. The mapping is subtly different to Google and uses a pastel pallet that is easy on the eye. In addition to the cartography, there is also relief shaded Digital Terrain Models (DTM) and Maps 3D which is a bit like Google Earth but not quite as easy to use. However, there is a neat 3D option if you have a suitable screen and glasses. Free accounts are capped at 1 million map views a month, slightly higher than the google limit.
Mobile friendly version is available
Advantages: Clean cartography. Looks different to the usual maps. Mobile friendly api
Disadvantages: User community even smaller than Bing maps. Maps 3D not as intuitive as it could be. DTM has artifacts in it that may be annoying. Aerial Imagery not as up-to-date as Bing/Google. Not entirely free.

Openlayers

OpenLayers is an open source JavaScript library for displaying map data in web browsers. It provides an API for building rich web-based geographic applications similar to Google Maps and Bing Maps. OpenLayers is used by the OpenStreetMap project for its slippy map interface which is very similar to Google maps in terms of usability. OpenLayers is used in many web map interfaces including EDINA’s Digimap services.

OpenLayers

The nice thing about OpenLayers is that the user community is both large and very active. This means that you can usually find the answer to the questions that you have when developing an interface. In addition, there are plenty of example maps which allow you to view the code and therefore learn how to implement solutions quite simply.
From Version 2.10, OpenLayers supported built in Navigation and TouchNavigation. Other features such as Map Dragging and Pinch Zoom are also supported. provider the mobile browser support touch events.

Leaflet 

Leaflet

Leaflet is a modern open-source JavaScript library for mobile-friendly interactive maps. It is very similar in style and function to the Openlayers API. It has slightly less features than the Opnelayers API, however this has the advantage of possibly making the API more straightforward. The other biggest, or smallest, advantage that Leaflet has is it’s size. The library is a svelte 64K (Openlayers is over 700k).

One of the trickier aspects of Leaflet is using your own local projection, such as OSGB, rather than the standard Web Mercator.  If you want to do this, then i would suggest reading this blog post which documents the process.

Modest Map

To be added

Map Quest

To be added

IGIBS Followon and use of Underspend

Its a bit early to be making predictions about how IGIBS might evolve, but a recent presentation to the EDINA geoteam followed by some discussion indicated some of the possibilities.

  • The WMS Factory Tool.  With the simple but effective styling capability that Michael Koutroumpas engineered, I think we have a prototype thats not too far off a production strength tool.  There are loads of scenarios where its valuable to have access to a tool that makes it easy to see your “non-interoperable” data alongside the growing number of INSPIRE View Services (read WMS) from public authorities across Europe going online.  So top of my list is improving this tools styling capability.
  • Associated with this would be better understanding of necessary data publication infrastructure, eg, making it easy to use the other OGC Web Services.  Something like the GEOSS Service Factory ideas emerging from the EuroGEOSS project.  I think there is a real demand for tools to make it easy to use the OGC standards.
  • In the immediate future, I think its likely that the IGIBS team will do some promotion of the project outputs, eg:
    • presenting the project at relevant events, eg, Association GI Laboratories Europe conference, OGC Technical Committee meetings.  This might cost as little as £500 depending on where the event is.
    • use of social media to promote both the WMS Factory Tool and the report on “Best Practice Interaction with the UK Academic Spatial Data Infrastructure”.  This too could cost as little as an additional £500.
  • The latter report is worthy of a lot more investment.  A major output from this project, possibly the single most important output, is the increase in use of UK academic SDI services within the Institute of Geography and Earth Science (IGES) at Aberystwyth University.  IGES is acting as an exemplar for best practice research data management around geospatial data, the department is actively building on the IGIBS work and it will be interesting to see how it develops and if other departments in other institutions see the benefit and start to emulate what Aberystwyth is doing.  More work promoting Steve Walsh’s report would help.

Licensing for blog content, source code and data

The blog content is licensed under the Creative Commons Attribution 3.0 Unported Licence.

IGIBS source code, i.e. the WMS Factory tool and the Mapping Application, is released under the modified BSD license. The full licence text will be included in any released source bundle.

The data licence(s) chosen depend on the original input data used. The WMS Factory tool will generate data (maps and tabular data) based on user-uploaded data which belong to their respective owners.

OpenStream WMS service for ac.uk

A new web mapping service is now available that makes the Ordnance Survery Open datasets available through WMS. The service offered by EDINA is initially available to anyone with an “ac.uk” email and requires a simple email activated registration. Other than that, there are no restrictions on use. The website includes an example mapping app using OpenLayers and isntructions on how to use the service with Google Earth. We also created a mobile app using this datasource, as described in a previous post on the TouchMapLite interface.

the data products available are:

  • GB Overview
  • Miniscale
  • 1:250000 Colour Raster
  • Vector Map District Raster
  • OS Streetview

you can register for the service (initially ac.uk email addresses only) here.

If you would like to find out how you can use Digimap OpenStream with desktop GIS you should read the Go-Geo! Blog.