Two New Data Modules for Bing Maps V7

 

By Ricky Brundritt, EMEA Bing Maps Technology Solution Professional

In September of 2011 we started the Bing Maps v7 Module CodePlex Project. The purpose of this project is to create a centralized location where developers could find and share useful modules that expand the functionality of the Bing Maps V7 API. Since the start of the project, we’ve had 15 modules submitted.

Today, I would like to highlight the two newest modules added to the project and provide a few updates to existing modules.

GeoJSON Module

Download here

This module was created by Brian Norman a Microsoft Bing Maps MVP from Earthware Ltd.

This module allows you to import GeoJSON files into Bing Maps. A GeoJSON feed will be downloaded and parsed into an EntityCollection which can then be added to the map. Additional properties are captured and stored in a Metadata tag on each shape making it easy to relate shapes to their metadata.

GeoJSON is a data format standard used for representing geospatial objects in JSON (JavaScript Object notation). JSON is much more compact than XML which makes it a great format for sharing spatial data online. In fact the AJAX Map DataConnector uses GeoJSON to send spatial data from SQL Server to Bing Maps.

Well Known Text Reader/Writer Module

Download here

I created this module because I wanted a simple tool for quickly visualizing Well Known Text on Bing Maps. This module allows you to easily read and write Well Know Text data from Bing Maps. When reading Well Known Text data it is parsed into Bing Maps shapes; MultiPoint, MultiLinstring, MultiPolygon and GeometryCollection are turned into an EntityCollection of shapes. To write Well Known Text simply pass in a Bing Maps shape and the Well Known Text equivalent will be returned.

clip_image004

Well Known Text (WKT) is an OGC (Open Geospatial Consortium) standard for representing Geospatial Data. In fact WKT is supported by the spatial types in Microsoft SQL Server 2008 and above as well as SQL Azure.

*Project Idea: Combine this module with the Shape Toolbox Module and make it easy for your users to draw on the map and upload the shape data into Microsoft SQL Server.

*Demo Tip: Use this module to quickly create demos that render complex spatial data. Simply store your Well Known Text in a JavaScript file as a string to save time setting up a web service to connect to your database. Note: this approach is not recommended for production applications as loading all the spatial data via a JavaScript file can make for slow loading of your application.

Other Data Related Modules

GeoRSS Module – GeoRSS is a common XML file format for sharing spatial data as a syndication feed. This module also supports GML, an OGC compliant XML format. This module has been updated to support Complex Polygons (polygons with holes).

GPX Module – GPX is a common XML data format that is used by GPS devices. Many GPS devices allow you to stave points, routes and tracks which can then be exported from the device in GPX format. This module makes it easy to view these files on Bing Maps.

The New Bing Maps Features

 

Coming back after the holiday season with a lot of energy, the Bing Maps team kicked off 2012 with releases of a new routing engine and the WPF control. Today–only 2 weeks later–we are now announcing several new features in the Bing Spatial Data Services and the Bing Maps Account Center. New features include a data source for traffic incidents, the ability to find points of interest (POI) along a route, wildcard-searches in your POI, incremental updates of POI data sources, improved reporting and more. Happy New Year! Are you feeling the love? Smile

The Bing Spatial Data Services provide a REST interface that allows you to geocode or reverse-geocode your own POI data sources in batch-mode, manage these data sources and query your own or some public POI data sources that Bing Maps provides in a spatial context.

Finding Traffic Incidents Along a Route using the new Spatial Data Services Query

In this release, we added the following features:

  1. Incremental Upload - Your own data sources now support incremental updates by setting the parameter ‘loadOperation’ in the Data Source Management API to ‘incremental’. So, once you’ve uploaded a data source of X number of locations into the Spatial Data Service, if you just want to add a few records you can just send those few records. We’ll handle the add and update functions for you!
  2. Wildcard Searches - New Query Options support wildcard searches through filter criteria. Let’s say you want to query your data source to find the nearest locations around a point AND you want to filter the results based on the beginning or end of a keyword. For example, let’s say you have a “Store Manager” field in your data source. You can look for said manager by last name, “%Smith” or first name “John%” so you get all the Smiths or Johns within a region.
  3. Traffic Incidents - Traffic Incidents for North America are now available as a public POI data source and can be accessed through the Query API. Now the traffic incidents you see on Bing Maps are available to you in your applications via a spatial query.
  4. Find Near Route - The Bing Spatial Data Service supports now an additional spatialFilter which allows you to search for POI along a route. This is a game changer. Let’s say you’re a coffee company and you want to empower your users to have the ability find all your locations along their drive from, say Seattle to San Francisco…now you can! The Find Near Route Feature allows you to spatially query the points you’ve uploaded into SDS within a 1 mile buffer of your route.

http:// spatial.virtualearth.net /REST/v1/data/
439698230d90496596083f3fe7aafeb2/
TrafficIncidents/
TrafficIncident
?key=[YOUR_BING_MAPS_KEY]
&$format=json
&jsonp=callbackFindTrafficIncidentsNearRoute
&spatialFilter=nearRoute(’47.678558349609375,-122.13098907470703′,
’47.60356140136719,-122.32943725585937′)

You will find a complete sample using the Bing Maps AJAX Control version 7 for visualization, the DirectionsManager class for driving directions, the TrafficLayer class for traffic-flow information and the Bing Spatial Data Services for traffic-incident information along a route here. Alternate versions of the SDK are available in PDF and .chm format, as well.

Note: Neither the Wildcard-search nor the spatial-filter ‘nearRoute’ are supported with the public data sources NAVTEQNA and NAVTEQEU.

The Bing Maps Account Center is the portal through which you can find information for development with Bing Maps, and also manage your account. It contains links to interactive and traditional SDKs, a facility to generate Bing Maps Keys, a web user interface to manage your own POI data sources and a reporting service through which you can retrieve statistics about your Bing Maps usage.

In this latest release we added the following features.

  1. Additional data validation has been introduced for the upload of your own POI data sources.
  2. Before it was already possible to add and edit records in a data source that you uploaded through the portal. You can now also download and delete data sources.M32small
  3. Image capturing adds now additional security during the generation of Bing Maps Keys.M33small
  4. Additional reports have been added to provide more details on the use of specific Bing Maps Keys.M34small

We certainly hope you’re feeling special (and spatial!). We’re investing quite a bit of energy into Bing Maps and hope to see some killer apps.

Now you can test your Mobile Web Apps with WebDriver

Mobile testing has come a long way since the days when testing mobile web applications was mostly manual and took days to complete. Selenium WebDriver is a browser automation tool that provides an elegant way of testing web applications. WebDriver makes it easy to write automated tests that ensure your site works correctly when viewed from an Android or iOS browser.

For those of you new to WebDriver, here are a few basics about how it helps you test your web application. WebDriver tests are end-to-end tests that exercise a web application just like a real user would. There is a comprehensive user guide on the Selenium site that covers the core APIs.

Now let’s talk about mobile! WebDriver provides a touch API that allows the test to interact with the web page through finger taps, flicks, finger scrolls, and long presses. It can rotate the display and provides a friendly API to interact with HTML5 features such as local storage, session storage and application cache. Mobile WebDrivers use the remote WebDriver server, following a client/server architecture. The client piece consists of the test code, while the server piece is the application that is installed on the device.

Get Started


WebDriver for Android and iPhone can be installed following these instructions. Once you’ve done that, you will be ready to write tests. Let’s start with a basic example using www.google.com to give you a taste of what’s possible.

The test below opens www.google.com on Android and issues a query for “weather in san francisco”. The test will verify that Google returns search results and that the first result returned is giving the weather in San Francisco.

public void testGoogleCanGiveWeatherResults() {
// Create a WebDriver instance with the activity in which we want the test to run.
WebDriver driver = new AndroidDriver(getActivity());
// Let’s open a web page
driver.get(“http://www.google.com”);

// Lookup for the search box by its name
WebElement searchBox = driver.findElement(By.name(“q”));

// Enter a search query and submit
searchBox.sendKeys(“weather in san francisco”);
searchBox.submit();

// Making sure that Google shows 11 results
WebElement resultSection = driver.findElement(By.id(“ires”));
List searchResults = resultSection.findElements(By.tagName(“li”));
assertEquals(11, searchResults.size());

// Let’s ensure that the first result shown is the weather widget
WebElement weatherWidget = searchResults.get(0);
assertTrue(weatherWidget.getText().contains(“Weather for San Francisco, CA”));
}

Now let’s see our test in action! When you launch your test through your favorite IDE or using the command line, WebDriver will bring up a WebView in the foreground allowing you to see your web application as the test code is executing. You will see www.google.com loading, and the search query being typed in the search box.


We mentioned above that the WebDriver supports creating advanced gestures to interact with the device. Let’s use WebDriver to throw an image across the screen by flicking horizontally, and ensure that the next image in the gallery is displayed.

WebElement toFlick = driver.findElement(By.id(“image”));
// 400 pixels left at normal speed
Action flick = getBuilder(driver).flick(toFlick, 0, -400, FlickAction.SPEED_NORMAL)
.build();
flick.perform();
WebElement secondImage = driver.findElement(“secondImage”);
assertTrue(secondImage.isDisplayed());

Next, let’s rotate the screen and ensure that the image displayed on screen is resized.


assertEquals(landscapeSize, secondImage.getSize())
((Rotatable) driver).rotate(ScreenOrientation.PORTRAIT);
assertEquals(portraitSize, secondImage.getSize());

Let’s take a look at the local storage on the device, and ensure that the web application has set some key/value pairs.


// Get a handle on the local storage object
LocalStorage local = ((WebStorage) driver).getLocalStorage();
// Ensure that the key “name” is mapped
assertEquals(“testUser”, local.getItem(“name”));

What if your test reveals a bug? You can easily take a screenshot for help in future debugging:


File tempFile = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE);

High Level Architecture

WebDriver has two main components: the server and the tests themselves. The server is an application that runs on the phone, tablet, emulator, or simulator and listens for incoming requests. It runs the tests against a WebView (the rendering component of mobile Android and iOS) configured like the browsers. Your tests run on the client side, and can be written in any languages supported by WebDriver, including Java and Python. The WebDriver tests communicate with the server by sending RESTful JSON requests over HTTP. The tests and server pieces don’t have to be on the same physical machine, although they can be. For Android you can also run the tests using the Android test framework instead of the remote WebDriver server.

Infrastructure Setup

At Google, we have wired WebDriver tests to our cloud infrastructure allowing those tests to run at scale and making it possible to have them run in our continuous integration system. External developers can run their mobile tests either on emulators/simulators or real devices for Android and iOS phones and tablets.
Android emulators can run on most OSes because they are virtualized, so we run them on our generic cloud setup. Though there are many advantages to using Android emulators because they emulate a complete virtual device (including the virtual CPU, MMU, and hardware devices), it makes the test environment slower. You can speed up the tests by disabling animations, audio, skins, or even by running in the emulator headless mode. To do so, start the emulator with the options –no-boot-anim, –no-audio, –noskin, and –no-window. If you would like your tests to run even faster, start the emulator from a previously created snapshot image. That reduces the emulator startup time from 2 minutes to less than 2 seconds!
iOS simulators can’t be virtualized and hence need to run on Mac machines. However, because iOS simulators don’t try to emulate the virtual device or CPU at all, they can run as applications at “full speed,” this allows the test to run much faster.
Stay tuned for more mobile feature in Selenium WebDriver, and updates on the Selenium blog.