Skip to content

Map Provider Gotchas

vicchi edited this page Jan 28, 2013 · 9 revisions

CloudMade

Map Controls

CloudMade does not support a stand-alone pan control; calling mxn.Mapstraction.addControls({ pan : true }); will have no effect.

Map Types

The CloudMade mapping library supports five map tile types; web, mobile, mapnik, osmarender and cycle. With the exception of the web map type, none of these map to the standard Mapstraction map tile types, so effectively CloudMade only supports a single map tile type which corresponds to mxn.Mapstraction.ROAD. Calls to mxn.Mapstraction.setMapType(type) will have no effect and calls to mxn.Mapstraction.getMapType() will always return mxn.Mapstraction.ROAD.

ESRI

The ESRI ArcGIS mapping library supports four stylesheet themes; the default for Mapstraction is claro but you can also use themes called tundra, soria or nihilo.

Regardless of which theme you choose, you need to ensure that you ...

  • Include the correct stylesheet
  • Set the HTML body tag to use the CSS class that corresponds to the theme

Theme Stylesheets

  • For claro include http://serverapi.arcgisonline.com/jsapi/arcgis/3.2/js/dojo/dijit/themes/claro/claro.css.
  • For tundra include http://serverapi.arcgisonline.com/jsapi/arcgis/3.2/js/dojo/dijit/themes/tundra/tundra.css.
  • For soria include http://serverapi.arcgisonline.com/jsapi/arcgis/3.2/js/dojo/dijit/themes/soria/soria.css.
  • For nihilo include http://serverapi.arcgisonline.com/jsapi/arcgis/3.2/js/dojo/dijit/themes/nihilo/nihilo.css.

Theme Body Class

Each theme also requires that your web page's body uses a style that corresponds to your theme. You can hardcode this into your web page ...

<body class="claro">

.. you can inject this via Javascript ...

<script type="text/javascript">
window.onload = function() {
	document.body.className = 'claro';
};
</script>

... or, if you're using jQuery ...

<script type="text/javascript">
$(document).ready(function() {
	$(document.body).addClass('claro');
});
</script>

Loading The Map

ESRI needs the entire HTML document of your web page to have loaded and also needs all the map tiles for the viewport of your map at the required zoom level to have been loaded and cached by your browser before you can perform any other operation on the map.

Effectively this means that your web page needs to have a load event handler registered and this event handler needs to create your map, register a Mapstraction load event handler and in this event handler you need to specify the center of your map and its zoom level.

In plain Javascript you'd do something like this ...

var map;

function load_map() {
	map = new mxn.Mapstraction('map', 'esri');
	map.load.addHandler(function(eventName, eventSource, eventArgs) {
		latlon = new mxn.LatLonPoint(51.50730, -0.12763);
		map.setCenterAndZoom(latlon, 12);
	});
}

window.onload = function() {
	load_map();
};

In jQuery you'd do something like this ...

var map;

function load_map() {
	map = new mxn.Mapstraction('map', 'esri');
	map.load.addHandler(function(eventName, eventSource, eventArgs) {
		latlon = new mxn.LatLonPoint(51.50730, -0.12763);
		map.setCenterAndZoom(latlon, 12);
	});
}

$(document).ready(function() {
	load_map();
});

In Dojo you'd do something like this ...

var map;

function load_map() {
	map = new mxn.Mapstraction('map', 'esri');
	map.load.addHandler(function(eventName, eventSource, eventArgs) {
		latlon = new mxn.LatLonPoint(51.50730, -0.12763);
		map.setCenterAndZoom(latlon, 12);
	});
}

dojo.addOnLoad(function() {
	load_map();
});

Leaflet

Map Controls

Leaflet supports a single size of unified pan and zoom control, as a result calling mxn.Mapstraction.addSmallControls(), mxn.Mapstraction.addLargeControls() or mxn.Mapstraction.addControls() and specifying the pan or zoom arguments will all have the same effect, namely adding the unified pan and zoom control if it's not already visible.

Map Types

Leaflet supports the mxn.Mapstraction.ROAD and mxn.Mapstraction.SATELLITE map types; the mxn.Mapstraction.HYBRID and mxn.Mapstraction.PHYSICAL map type are unsupported.

Ordnance Survey OpenSpace

The OS OpenSpace mapping library supports maps for the United Kingdom only; in other words for England, Scotland, Wales and Northern Island.

OpenSpace also only supports a single map tile type which corresponds to mxn.Mapstraction.ROAD. Calls to mxn.Mapstraction.setMapType(type) will have no effect and calls to mxn.Mapstraction.getMapType() will always return mxn.Mapstraction.ROAD.

Microsoft v6.3

Map Controls

The Microsoft/Bing v6.3 mapping library encapsulates all the map controls into a single entity called the dashboard, the size of which can only be set before the map is loaded. As a result, regardless of what size of zoom control is requested, calling mxn.Mapstraction.addControls() and requesting either the pan control or the zoom controls will only show a previously hidden dashboard if the dashboard is not already visible.

Map Types

Microsoft/Bing v6.3 supports the mxn.Mapstraction.ROAD, mxn.Mapstraction.SATELLITE and mxn.Mapstraction.HYBRIDmap types; themxn.Mapstraction.PHYSICAL` map type is unsupported.

Microsoft v7

As with v6.3, v7 of the Microsoft/Bing mapping library supports a single dashboard containing all the map controls. Furthermore, the visibility of both the dashboard and the scale bar can only be set before the map is loaded and an overview map control is not supported at all. As a result, calling mxn.Mapstraction.addControls(), mxn.Mapstraction.addSmallControls(), mxn.Mapstraction.addLargeControls() or mxn.Mapstraction.addMapTypeControls() will have no effect.

Map Types

As with v6.3, v7 supports the mxn.Mapstraction.ROAD, mxn.Mapstraction.SATELLITE and mxn.Mapstraction.HYBRID map types; the mxn.Mapstraction.PHYSICAL map type is unsupported.

Clone this wiki locally