Concepts
Get Started
- Pre-Requisites
- Install the NuGet Package
- Obtain Leaflet
- Obtain a License
- Initialize Mapzania
- Initialize Endpoints
- Adding a JavaScript Reference
- Add a Map to a Web Page
- Add Data to a Map
- Style a Map
- Further Reading
JavaScript Client
- Introduction
- Creating a Map Object
- Customize the Map Toolbar
- Map Events
- Mouse and Drawing Behaviour
- Map Extents
- Refresh/Reset the Map
- Working with Layers
- Displaying Layers
- Working with Layer Data
- Styling Layers
- Transforming Layers
- Working with Features
- Displaying Features
- Styling Features
- Working with the QueryEngine
DotNet Server
Setting Up
Register a License
To activate Mapzania, you will need a license. Click here to get one.
The next step is to register your license. This can be done in three ways as described below.
1. Register license in source-code
See Initialize Mapzania section below.
2. Register license as appSettings in web.config file
<configuration>
<appSettings>
...
<add key="Mapzania_LicenseKey" value="[your license key]"/>
</appSettings>
...
</configuration>
3. Register license in Mapzania.license file
- Create a text file and paste your license key into the file.
- Rename the text file to Mapzania.license.
- Place the file in the root of your project (same folder as web.config).
NOTE: If all options are configured, precedence is option 3 then 2 then 1.
Initialize Mapzania
To initialize Mapzania, add the code highlighted below to the Application_Start method in your global.asax file:
void Application_Start(object sender, EventArgs e)
{
...
// ** Start Mapzania (default) **
Mapzania.Services.Start(this);
//// ** Start Mapzania (with options including license) **
//Mapzania.Services.Start(this, new Mapzania.Config {
// LicenseKey = "[your license key]"
//});
AreaRegistration.RegisterAllAreas();
GlobalConfiguration.Configure(WebApiConfig.Register);
RouteConfig.RegisterRoutes(RouteTable.Routes);
BundleConfig.RegisterBundles(BundleTable.Bundles);
...
}
See Mapzania.Services.Start for reference documentation.
Initialize Endpoints
Method 1 - .NET MVC Projects without WebApi
To initialize the Mapzania endpoints, add the highlighted code to the Application_Start method in your global.asax file:
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);
RouteConfig.RegisterRoutes(RouteTable.Routes);
BundleConfig.RegisterBundles(BundleTable.Bundles);
}
Method 2 - .NET MVC Projects with WebApi
To initialise the Mapzania endpoints, add the highlighted code to the Register method in your WebApiConfig.cs file (located in the App_Start folder):
public static void Register(HttpConfiguration config)
{
config.MapHttpAttributeRoutes();
//Register Mapzania Routes (endpoints)
Mapzania.Services.RegisterRoutes(config);
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
}
NOTE: 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.
Build your application.
To test that the endpoints have been added successfully, try this url on your site: http://your-site/mz/maps. If the endpoint is working successfully, you should see JSON data.
See Mapzania.Services.RegisterRoutes for reference documentation.
Also, see the REST Documentation for more details on the endpoints that are now available in your project.