Interactive Mapping Blog

Mapping Solutions News

Archive for the ‘Web Development’ Category

5 ways to make your web mapping fly!

Monday, March 28th, 2011

map paper planeOver the past four years here at Earthware we have encountered a number of performance challenges when creating mapping applications on the web. We thought it might be helpful to bring together the 5 most common issues we’ve encountered, both when helping other developers or in some of our older mapping projects.

It’s unfair to call these mistakes, rather they are missed opportunities to make your mapping really fly. They are not exclusively focused on specific mapping API’s or web programming languages / frameworks so they should be applicable to the majority of web mapping applications with a little translation.

So in no particular order:

1. How accurate do you really need to be?

We often come across systems or code samples that both store, but more importantly transfer their position data (usually pairs of lat/lon) to very high levels of decimal places (often 13 or more decimal places). Did you know that 8 decimal places of accuracy is a real world value of 1.11 millimetre (at worst when on the equator). How many systems have you worked on that require you to map to 1.11 millimetre accuracy?

So assuming that for most of us meter accuracy is plenty enough we can reduce our values to only use 5 decimal places (1.11 metre accuracy). When transferring either points, or more importantly polygon data reducing your data from 13 to 5 decimal places is likely to decrease the amount of data you are transferring by at least half.

Typical speed improvement: 50%!

2. Load small, load often

Many mapping applications allow the user to drill into the detail of the data shown on the map. In the majority of cases the user does not require the full details of every single piece of data so why bother loading them all?

Typically in the mapping applications we encounter the initial view a user is presented with has a number of pushpins / polygons maybe with a text label and or an icon representing the ‘type’ of data shown (like a hotel, house, pipe etc). So the data we need to initially load for each point is a title, latitude, longitude, type and unique id. We don’t need to load all the description, photos, links or other data that will not be shown until the user clicks the icon/polygon.

At Earthware, the way we normally handle this is to have two services, one that returns the initial map data that matches our query, and one that returns the full details for a single selected entity. You can code your map so that it makes a call to the “full details” service when a user clicks a map entity and in our experience returning the data for a single entity is usually so quick the user doesn’t even notice the slight pause.

To see an example of this service architecture using asp.net and Bing Maps see http://bingmaps.codeplex.com/wikipage?title=Getting%20Started%20in%20Web%20Services&referringTitle=Home

Typical initial map load improvement: > 500%

3. Don’t repeat yourself

Often when helping developers improve their JavaScript map performance we come across an approach to loading the map data that we don’t recommend except in the most simplistic applications. That approach is to generate the JavaScript code on the web server that is used to create entities on the map and to pass this chunk of JavaScript back to the client and execute it there. For example, we see a service return the following JavaScript:

var pin = new Microsoft.Maps.Pushpin(52.011,-0.221, {text: '1'});
map.entities.push(pin);
pin = new Microsoft.Maps.Pushpin(53.011,-0.121, {text: '2'});
map.entities.push(pin);
pin = new Microsoft.Maps.Pushpin(51.011,-0.251, {text: '3'});
map.entities.push(pin);
pin = new Microsoft.Maps.Pushpin(50.011,-0.321, {text: '4'});
map.entities.push(pin);
pin = new Microsoft.Maps.Pushpin(54.011,-0.143, {text: '5'});
map.entities.push(pin);
pin = new Microsoft.Maps.Pushpin(55.011,-0.0123, {text: '6'});
map.entities.push(pin);

This approach seems to be popular with developers because it’s quick and simple to achieve. However, the downside is that you are constantly repeating the same long text phrases and transferring all these repeats to your user, thus slowing down their mapping experience to make it easier for you to code. This data could be sent in a simple data structure, like JSON, and with some simple code looped through and added to the map. The same data above in JSON would look like:

{points:{point:[{title:1,lat:52.021,lon:-0.211},
  {title:2,lat:53.011,lon:-0.121},
  {title:3,lat:51.011,lon:-0.251},
  {title:4,lat:50.011,lon:-0.321},
  {title:5,lat:54.011,lon:-0.143},
  {title:6,lat:55.011,lon:-0.0123}

]}}

To see an example of this data transfer architecture using Asp.net, JSON and Bing Maps see http://bingmaps.codeplex.com/wikipage?title=Getting%20Started%20in%20Web%20Services&referringTitle=Home

Typical map data load improvement: > 100%

4. Some data you just can’t load fast enough

As we have recently blogged the latest Bing Maps AJAX API is now even faster at showing pushpins on a map, but there is still a limit especially when you are working with older browsers. If your data consists of thousands of entities then it won’t take long before you either cannot transfer the data fast enough or the performance of your map is too slow.

So what can you do? Your users still need to be able to search all the data so you cannot just remove some. The most common solution to this problem is ‘clustering’ of map entities. This is where you group together nearby or overlapping entities and only show individual entities once the user has zoomed in. This can be achieved either using client side code (see http://rbrundritt.wordpress.com/2011/03/02/client-side-clustering-in-v7/) or on the server side before you transfer the data to the client (see http://www.viawindowslive.com/Articles/VirtualEarth/ClusteringVirtualEarthwithMSAJAXandC.aspx). The advantage of doing this on the server side is that you do not have to transfer the data for each individual entity but instead can just transfer the data required to show the ‘clustered’ entity.

There are other approaches to this problem including generating rasterised image tiles of your data and only showing interactive map elements once the user has zoomed in. This works just as well for pushpins as it does polygons. A good example of this ‘hybrid’ approach is the open source ajax map data connector project on codeplex: http://ajaxmapdataconnector.codeplex.com/

5. Transferring data as plain text is soooo slooowwwww

We have already discussed ways of optimising the data you send your clients (in 3.) above but that approach still ends up transmitting plain text data to your clients. There are much better binary formats you could transfer the data in that would massively reduce the size of your transfers.

The first and easiest of these is to use a compression format called Gzip that is seamlessly built into all modern web browsers and plugins (Flash and Silverlight). If on your web service you compress all your map data using Gzip your clients browser will be able to atomically decompress the data ready for you code to use without you having to change you client side code at all. Gzip compression is usually very simple to enable on your web service (see these links for apache, iis6 and iis7).

This approach doesn’t just apply to data transfer or mapping and (if you are not already) you should look at compressing other ‘static’ files like your JavaScript and css.

If you are using Silverlight to load data from WCF services then an even better solution is to use the built in binary http protocol.

There is usually a slight CPU cost to compressing the data but on a modern processor this is minimal and well worth the decrease in data transfer sizes.

Typical map data load improvement: > 50%

In Summary

Hopefully some or all of these issues might help you make a real, measurable difference to your applications performance and many of them are quick and simple to achieve. We would love to hear your real world performance improvements if you do use any of these tips so please feel free to share them in the comments section below.

GoLearnTo continues to show how to place technology at the heart of the online experience

Thursday, August 12th, 2010

Now in our fourth year of partnership with GoLearnTo.com we are delighted that the website we have been involved in developing continues to go from strength to strength. In the last month GoLearnTo has added no less than four awards and nominations to their impressive array of successes including…

GoLearnTo.com

Tongue Twister

The International Association of Language Centres has voted GoLearnTo.com agency of the month recognising them as a leading language travel agency. The IALC recognize the quality and teaching standards of GoLearnTo.com’s range of courses where you can learn Spanish in Spain or learn French in France and over 14 more languages worldwide.

Best holiday experience provider…

GoLearnTo.com have been nominated for a British Travel award in the category ‘Best Holiday Experience Provider’. It’s a great honour to be nominated for the 2nd year running proving there’s no stopping the public’s appetite for learning new skills on holiday.

Best new agency…

Language schools from over 30 countries worldwide have voted for GoLearnTo.com in the best new agency category for Language Travel Magazine’s star awards. GoLearnTo.com has been specially recognized as a ‘star’ agency for their work to make language learning more fun and a holiday activity by combining languages with a unique range of fun activities such as cookery holidays in Italy, yoga holidays or even surfing, dancing, horse riding and much more.

And the website of the year goes to…

GoLearnTo hope to be in with a chance of winning the Good Web Guide’s Website of the Year Award after being nominated this year.

This proves once again how an aesthetically pleasing, functionally rich and easy to use website designed and developed by The Technology Studio with maps by Earthware can do for you.

We are also really excited to be working on a potentially groundbreaking project with GoLearnTo using Microsoft Silverlight and Bing Maps to offer a rich multimedia experience all within a map – watch this space!

Become Mayor of your town!

Friday, April 16th, 2010

Well, in a virtual sense at least. Foursquare is a fast-growing location-based game that allows you to ‘check-in’ to locations from your mobile device that is shared with users and your community of friends. As well as showing where people are, thanks to GPS technology, you can provide tips and advice about a specific location. Think of it in terms of a real-time version of Trip Advisor.

In offering this information, you earn ‘badges’ and when you’ve collected enough, you are considered influential enough to be given the keys to your city in the shape of a virtual ‘Mayorship’ of the location where you checked- in. This concept reflects foursquare’s slogan, “Unlocking your city.”

Microsoft recently commissioned the development of a new Application from the team at Earthware using the Silverlight Bing Maps Control so you can now see where Foursquare users are checking-in via Microsoft’s Bing Maps in real time.

image

Click on ‘Map Apps’ bottom left and you’ll see a menu which shows Foursquare Everywhere. The mapping facility within the App is seamless, enabling ultra-fast zoom functionality. As it loads, you’ll see tips from users who have tagged a location with additional information. A continually updated flow of ‘check-ins’ is presented on the left of the screen and as you zoom out to a country or global view, Foursquare check-ins are indicated as pinpoints on the map.

Checking the box “auto-center the map on new updates” allows you to watch the map fly around the world as people check in everywhere!  If you’re not seeing data on the map, chances are you’re zoomed into an area where people aren’t playing Foursquare so either move the map or zoom out. If you click on one of the pieces of data pinned to the map you’ll get a pop up with the name of the location which you can click to zoom down.

Speaking at the Where 2.0 conference in California recently, Bing Maps’ architect Blaise Agüera y Arcas demonstrated the new Foursquare Everywhere feature on the Bing Maps platform, which was a proud moment for the Earthware team. Agüera y Arcas described the service as a “mash-in” rather than a “mash-up”, with Bing Maps working as a surface on top of which different applications and services can be integrated.

“With a mash-in model like this, the interaction is much more rich and fluid than with a traditional mash-up technique, as everything is discoverable in one place,” he said.

Ensuring user privacy, Bing Maps only shows information from the Foursquare API that users have agreed to share. Users can select their own privacy settings, allowing them to decide if they want to share their location, for example. Bing Maps doesn’t store any user information provided through the Foursquare Everywhere App, as it streams data directly to the map in real time.

If you would like to find out more about map Apps, Bing Maps or Silverlight please get in touch with us.

Earthware help Rovster launch a new type of property website

Monday, October 26th, 2009

Earthware are delighted to have been invited by Gary McCausland (from BBC1’s “Axe the Agent” to do the web design, web development, interactive mapping and SEO (Search Engine Optimisation) for his new venture Rovster.

Rovster allows a property owner who wants to “sell my house privately” to sign up and advertise online with a free property listing.  Whether you have flats to rent, property to rent or you want to buy a property in … or sell my house in …. then Rovster is seeking to debunk the property market.

We are delighted that not only did Gary decide to integrate Earthware interactive property mapping but also to use our sister, The Technology Studio to do the web design and development.

We wish Gary every success with Rovster!

The Earthware team

Using Virtual Earth Webservices with PHP

Wednesday, January 14th, 2009

This last week we have been working on a Virtual Earth project with a client who have a large php extranet . As part of the mapping integration we have been helping their developers use the Virtual Earth webservices for Geocoding addresses but there seem to be no up to date code samples for doing this in PHP.

The Soap Options

There are a few options for calling SOAP webservices in PHP, the two most popular seem to be NuSoap and the PHP5 built in SoapClient. Most of the previous PHP examples for calling the older MapPoint web services are using NuSoap I believe because of early issues with the built in SoapClient, so that is where we started.

NuSoap

We managed to get the GetClientToken method working using NuSoap pretty quickly but came across issues when we started trying to call the geocodeservice. Initially we found an issue with the encoding of the SOAP request being rejected by the geocodeservice but after some digging found an option to change it in NuSoap by uncommenting the line "var $soap_defencoding = ‘UTF-8′;" in nusoap.php.

Once we had that working, we were getting errors suggesting we were not sending a Credentials parameter to the GeoCode method, even though we were. We tried lots of different approaches including creating the SOAP envelope by hand and sending it using NuSoap but nothing seemed to work. So we started again and this time tried the PHP5 built in SoapClient.

PHP5 SoapClient

After converting the code to the PHP5 SoapClient we started to have some joy with the GeoCode method and eventually managed to get it to return a result. With a bit of debugging to see the structure of the result we eventually had access to the GeoCodeResult object and its properties!

So rather than using two different SOAP clients we now changed our GetClientToken code to use the PHP5 SoapClient, but again it didn’t exactly go to plan. The PHP5 SoapClient does not seem able to download a password protected WSDL, even when using it’s documentation credentials options. We tried putting the username/password in the wsdl url but that didn’t work either so eventually we had to download a local copy of the wsdl and use that.

The Final Code

The code is split into two parts, the token request:

  //used to get Virtual Earth webservice token, returns token as string
  function GetToken($vepUID,$vepPWD){

    //have to use local copy as cannot get php to send credentials to get it from live. See http://bugs.php.net/bug.php?id=27777 for php bug report
    //remember to update local wsdl when using production
    $vetsWsdl = 'tokenservice.wsdl';
    //attempted at sending credentials in url, does work
    //$vetsWsdl = 'http://' . $vepUID . ':' . $vepPWD . '@staging.common.virtualearth.net/find-30/common.asmx?wsdl';
    //live url $vetsWsdl = 'http://' . $vepUID . ':' . $vepPWD . '@common.virtualearth.net/find-30/common.asmx?wsdl';

    //create soap client, setting username and password used when calling method
    $client = new SoapClient($vetsWsdl, array('login'=>$vepUID,'password'=>$vepPWD,'trace' => 1));//trace allows us to see last response and request for debugging

    $client_ip = $_SERVER['REMOTE_ADDR'];//wont work for localhost!
    //$client_ip = '86.17.152.241';

    //Build the tokenspecification object http://msdn.microsoft.com/en-us/library/cc966768.aspx
    $tokenSpecification = array(
        'ClientIPAddress' => $client_ip,
        'TokenValidityDurationMinutes' => 15);
    $getClientToken = array('specification' => $tokenSpecification);

    //call GetClientToken method of token service http://msdn.microsoft.com/en-us/library/cc980876.aspx
    $result=$client->GetClientToken($getClientToken);

    //Make sure no fault or error has occurred.
    if ($client->fault)
    {
      die('Fault occurred using Web Service: '.print_r($res,true));
    }
    $veToken = $result->GetClientTokenResult;
    return $veToken;
  }

and the GeoCode request:

  //Virtual Earth Platform ID goes here.
  $vepUID = 'YOURUSERID';
  //Virtual Earth Platform password goes here.
  $vepPWD = 'YOURPASSWORD';

  $veToken = GetToken($vepUID,$vepPWD);//call token function

  //Get geocode
  $vegWsdl = 'http://staging.dev.virtualearth.net/webservices/v1/metadata/geocodeservice/geocodeservice.wsdl';
  //live url $vegWsdl = 'http://dev.virtualearth.net/webservices/v1/metadata/geocodeservice/geocodeservice.wsdl';

  //Create soap client
  $client = new SoapClient($vegWsdl, array('trace' => 1));//trace allows us to see last response and request for debugging

  //create credentials object and fill properties http://msdn.microsoft.com/en-us/library/cc966923.aspx
  $credentials = array('Token' => $veToken);
  //set geocoding query
  $query = 'SG15 6YF, uk';
  //create geocoderequest object and fill properties http://msdn.microsoft.com/en-us/library/cc980924.aspx
  $geocodeRequest = array('Credentials' => $credentials,'Query' => $query);

  //build geocode methods 'request' parameter
  $geocode = array('request' => $geocodeRequest);

  //call web service method called GeoCode http://msdn.microsoft.com/en-us/library/cc966817.aspx
  $result=$client->Geocode($geocode);

  //Make sure no fault or error has occurred.
  if ($client->fault)
  {
    die('Fault occurred using Web Service: '.print_r($res,true));
  }

  //Get GeocodeResponse  object from $result http://msdn.microsoft.com/en-us/library/cc980928.aspx
  //get first GeocodeResult object as there will be more than one, starting with the most relevant. http://msdn.microsoft.com/en-us/library/cc980950.aspx
  //get the GeocodeLocation object http://msdn.microsoft.com/en-us/library/cc966778.aspx
  //get the Latitude value
  echo $result->GeocodeResult->Results->GeocodeResult[0]->Locations->GeocodeLocation->Latitude . '<br />';
  //get the Longitude value
  echo $result->GeocodeResult->Results->GeocodeResult[0]->Locations->GeocodeLocation->Longitude . '<br />';

 

Final Thoughts

It’s been a long time since we have done any real PHP coding and the one thing this exercise has reminded us is just how far .Net has come over the years compared to PHP. What would take minutes to do in .Net has taken hours to figure out and debug in PHP, and with no strongly typed objects it was even more difficult to get at the result objects. But we do not claim to be PHP experts, maybe there are easily and less taxing ways to achieve this, we would love to hear if you know more!

We Have Been Busy Web Developing Again.

Wednesday, October 22nd, 2008

Earthware have now made live their latest web development project, an online estate agency website for residential property in Buckinghamshire, DreamSpot.

The journey began back in April 2008 when the two Neil’s first met. Neil Osmond, Earthware’s Operations Director and Neil Wood Managing Director of DreamSpot wanted to discuss how Earthware could help with the development and launch of this new online estate agency. The first step was for Earthware to build schematics for the site. Upon receipt of this Neil Wood became sure his dream of a website that made buying and selling property in Buckinghamshire really easy was possible and asked Earthware to submit a formal proposal for the entire site development and launch. The result of this is now available for all to see at DreamSpot.co.uk and Neil Wood is very happy with the process as much as he is with the result.

clip_image002

“I just want to put in record how easy and enjoyable it has been working with all of you; I have always felt that the project was under control and at no stage was my confidence in your abilities to deliver unfounded! With all the other parts of setting up this business causing various amounts of stress it was so nice to know the major component, the website, was in capable hands.” Neil Wood, Managing Director, DreamSpot.

The site, which is split into two main sections, a buyer area and a seller area, aims to bring tomorrow’s estate agency services to the market today. Through being an online estate agent, DreamSpot are able to keep their overheads down, a saving which they pass on to their clients. But being online does not mean there is no-one to talk to or that you cannot control what is happening; not only can buyers ask the seller or the DreamSpot team a question using the websites messaging system they can book a viewing directly with the seller and the DreamSpot team are always at the end of a phone too.

In addition to developing the DreamSpot site, we have also implemented our residential property mapping, EarthwareProperty, allowing users to search for and see their next property in its actual location with road, aerial and Bird’s Eye imagery. Covering the Amersham, Beaconsfield, Chesham, High Wycombe, Chiltern and West Wycombe regions of Buckinghamshire, DreamSpot.co.uk provides information about what it is like to live in these areas of the county, as well as all providing financial and legal services for buyers and sellers and Home Information Packs (HIPs).

Contact DreamSpot to discover more about buying and selling property in Buckinghamshire or read the DreamSpot blog or if you are looking for web development services please contact us.