RegisterRoutes
The purpose of this method is to register the WebApi routes of the REST API and its controllers with your application. These endpoints are used by the JavaScript API for map interactions.
NOTE: This method must be called to activate Mapzania properly. Also, it is vital that you place this line after config.MapHttpAttributeRoutes() and before you define your default route with config.Routes.MapHttpRoute, otherwise the Mapzania endpoints may not initialize correctly.
Parameters
Name | Required | Type | Description |
---|---|---|---|
config | Yes | System.Web.Http.HttpConfiguration | The configuration object of the web server instance. |
options | No | Mapzania.RouteOptions | Options for route registration. |
Options
Name | Default | Type | Description |
---|---|---|---|
ApiRootUrl | "mz" | String | This will set the root URL for the Mapzania REST API to a custom URL. |
Examples
MVC Only
global.asax
protected void Application_Start()
{
// Start Mapzania
Mapzania.Services.Start(this);
AreaRegistration.RegisterAllAreas();
FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
//Register Mapzania Routes (endpoints)
Mapzania.Services.RegisterRoutes(GlobalConfiguration.Configuration, new RouteOptions {
ApiRootUrl="api/mapzania/1.0/"
});
RouteConfig.RegisterRoutes(RouteTable.Routes);
BundleConfig.RegisterBundles(BundleTable.Bundles);
}
WebApi
WebApiConfig.cs (or equivalent)
public static void Register(HttpConfiguration config)
{
config.MapHttpAttributeRoutes();
//Register Mapzania Routes (endpoints)
Mapzania.Services.RegisterRoutes(config, new RouteOptions {
ApiRootUrl="map_api/1.0/"
});
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
}