š GeoMapping.cshtml Documentation
Table of Contents
- Overview & Purpose
- Dependencies & Technologies
- View Model & Data Binding
- Layout & Razor Structure
- JavaScript Functional Areas
- UI Components & Syncfusion Controls
- Styling & CSS
- Sample Usage & Integration
- UML Diagrams
- Conclusion & Next Steps
1. Overview & Purpose
GeoMapping.cshtml is a Razor view under Views/LegalImaging that provides an interactive map-based interface for browsing, searching, and analyzing property lease data.
- š Key Features
- Displays geolocated lease properties on a Bing Map
- Supports business suggestions via Autosuggest
- Realātime user location tracking
- Directions and traffic overlay
- Tabular listing of properties with Syncfusion TreeGrid
- Modal popāups for lease details
This page is intended for legal and real estate teams to visualize lease locations, view their metadata, and export data efficiently.
2. Dependencies & Technologies
| Category | Details |
|---|---|
| Map Library | Microsoft Bing Maps V8 (via <script src="https://www.bing.com/api/maps/mapcontrolā¦">) |
| UI Components | Syncfusion EJ2 for JavaScript: ejs-textbox, ejs-treegrid, ejs-button |
| AJAX & Data Fetch | fetch() API for /Location/GetLocations; jQuery AJAX for modal content |
| DataTables | DataTables.net & Buttons (CSV/PDF/Excel export) |
| Server-side | ASP.NET MVC Razor, @model IrbyImaging.DomainClasses.GeoLocation |
| Modal & Layout | Bootstrap 5 modal & custom _LegalLayout.cshtml |
| Geolocation API | navigator.geolocation for realātime tracking |
| CSS Framework | Custom CSS + Bootstrap |
3. View Model & Data Binding
@model IrbyImaging.DomainClasses.GeoLocation
- Model: Exposes a single
GeoLocationobject. - ViewBag: Supplies
ViewBag.datasourcefor the Syncfusion TreeGrid (hierarchical property list).
4. Layout & Razor Structure
@{
Layout = "~/Views/Shared/_LegalLayout.cshtml";
}
<!DOCTYPE html>
<html lang="en">
<head>ā¦</head>
<body>
<!-- Search Box & Map Container -->
<div id="searchBoxContainer">ā¦</div>
<div id="myMap"></div>
<!-- Tracking Controls -->
<input value="Start Continuous Tracking" onclick="startTracking()" />
<input value="Stop Continuous Tracking" onclick="stopTracking()" />
<!-- Property List -->
<div id="propertyTable">ā¦</div>
<!-- Modal for Lease Details -->
<div id="myModal" class="modal">ā¦</div>
<!-- Scripts -->
</body>
</html>
- Razor Blocks at the top import namespaces:
@using Syncfusion.JavaScript; @using Syncfusion.JavaScript.Models; @using Syncfusion.EJ2;
5. JavaScript Functional Areas
5.1 Map Initialization: GetMap()
function GetMap() {
map = new Microsoft.Maps.Map('#myMap', {
credentials: '<YOUR_BING_KEY>',
supportedMapTypes: [ /* road, aerial, birdseye⦠*/ ],
mapTypeId: Microsoft.Maps.MapTypeId.aerial
});
// Infobox setup
infobox = new Microsoft.Maps.Infobox(map.getCenter(), { visible: false });
infobox.setMap(map);
// Click handler to close infobox
Microsoft.Maps.Events.addHandler(map, 'click', () => infobox.setOptions({visible: false}));
// Load modules: AutoSuggest, Traffic, SpatialDataServiceā¦
Microsoft.Maps.loadModule([...], function() { /* attach Autosuggest */ });
// Dynamically load location data afterwards
}
- Credentials need your own Bing Maps Key.
- Registers an infobox for displaying property details.
- Dynamically loads map modules for suggestions, traffic, etc.
5.2 Data Fetch & Rendering
fetch('/Location/GetLocations')
.then(res => res.json())
.then(locations => {
const bingLocations = locations.map(l => new Microsoft.Maps.Location(l.Latitude, l.Longitude));
locations.forEach(location => {
const pin = new Microsoft.Maps.Pushpin(new Microsoft.Maps.Location(location.Latitude, location.Longitude));
Microsoft.Maps.Events.addHandler(pin, 'click', () => showInfobox(pin, location));
map.entities.push(pin);
});
// Fit map to all pushpins
const bounds = Microsoft.Maps.LocationRect.fromLocations(bingLocations);
map.setView({ bounds });
});
- AJAX call to server endpoint, renders Pushpins for each lease property.
- Automatically fits map bounds to include all points.
5.3 Pushpin & Infobox Management
function showInfobox(pin, locationData) {
infobox.setOptions({ visible: false });
const content = `
<div style="ā¦">
<strong>${locationData.Address}</strong><br/>
⦠<a href="/LegalImaging/ViewDoc/${locationData.DocumentImageId}">View Lease</a>
</div>`;
infobox.setOptions({
location: pin.getLocation(),
htmlContent: content,
visible: true
});
// Re-center map if infobox overflows
// ⦠pixel-to-location adjustment ā¦
}
- Custom HTML in infobox: address, landlord, dates, cost, links.
- Dynamically re-centers if infobox overflows map boundaries.
5.4 AutoSuggest & Search
var manager = new Microsoft.Maps.AutosuggestManager({ map, businessSuggestions: true });
manager.attachAutosuggest('#searchBox', '#searchBoxContainer', suggestionSelected);
function suggestionSelected(result) {
map.entities.clear();
const pin = new Microsoft.Maps.Pushpin(result.location);
map.entities.push(pin);
map.setView({ bounds: result.bestView });
}
- Enables business suggestions and places a pushpin on selection.
5.5 Directions & Routing
Note: Directions Manager is partially commented out but structure remains.
function directionsUpdated(e) {
dataLayer.clear();
const currentRoute = directionsManager.getCurrentRoute();
// Build nearRoute query via SpatialDataService
Microsoft.Maps.SpatialDataService.QueryAPIManager.search(queryOptions, map, data => {
dataLayer.add(data);
});
}
- Fetches points of interest near the computed route.
- Supports driving/walking modes, optimization settings.
5.6 Realātime Geolocation Tracking
function startTracking() {
userPin = new Microsoft.Maps.Pushpin(map.getCenter(), { visible: false });
map.entities.push(userPin);
watchId = navigator.geolocation.watchPosition(usersLocationUpdated);
}
function usersLocationUpdated(position) {
const loc = new Microsoft.Maps.Location(position.coords.latitude, position.coords.longitude);
userPin.setLocation(loc);
userPin.setOptions({ visible: true });
map.setView({ center: loc });
}
function stopTracking() {
navigator.geolocation.clearWatch(watchId);
removePinById('uniqueIdentifier');
}
- Start/Stop continuous tracking of userās location.
- Uses
navigator.geolocation.watchPosition.
5.7 Utility & Helper Functions
| Function | Purpose |
|---|---|
removePinById(id) |
Removes pushpin metadataāmatched by metadata.id |
switchToBirdseye() |
Switch to birdās eye view if available |
mapClicked(e) |
Allows users to add draggable pins & metadata via form |
saveData() |
Saves input form data into the clicked pushpinās metadata |
pushpinClicked(e) |
Opens infobox for userācreated pushpin metadata |
highlight(id, event) |
Visual feedback for mouse events (drag, click) |
6. UI Components & Syncfusion Controls
- Search Box
<ejs-textbox id="searchBox" placeholder="Search for new location"></ejs-textbox> - TreeGrid for Properties
<ejs-treegrid id="TreeGrid" dataSource="@ViewBag.datasource" ā¦> <e-treegrid-columns> <e-treegrid-column field="Landlord" headerText="Property Name" width="220"></e-treegrid-column> <e-treegrid-column field="Address" ⦠width="150"></e-treegrid-column> <e-treegrid-column field="TypeList" template="#typetemplate"></e-treegrid-column> <e-treegrid-column field="BlobName" template="#viewtemplate"></e-treegrid-column> </e-treegrid-columns> </ejs-treegrid> - Modal Detail View: AJAXāloaded via jQuery
7. Styling & CSS
html, body { height: 100%; margin: 0; padding: 0; }
#myMap { width: 100%; height: 700px; float: right; }
#propertyTable { width: calc(100% - 380px); float: left; }
#inputForm { position: absolute; top: 200px; left: 250px; ⦠}
.darkZoom { background-color: #333; color: #fff; }
.lightZoom:hover { background-color: #ccc; }
- Responsive layout: Map and property list side by side.
- Custom pushpin form in absolute position.
8. Sample Usage & Integration
- Add your Bing Maps Key in the
<script>loader at the bottom:let bingKey = "<YOUR_KEY>"; script.src = `https://www.bing.com/api/maps/mapcontrol?callback=GetMap&key=${bingKey}`; - Ensure your API
/Location/GetLocationsreturns JSON:[ { "Latitude": 47.6, "Longitude": -122.3, "Address": "...", "Landlord": "..." , ⦠} ] - Bind the TreeGrid datasource in your controller:
ViewBag.datasource = GetPropertyHierarchy(); // IEnumerable<GeoLocation> return View(); - Run the page; search, pan/zoom, click pushpins, view details, export table.
9. UML Diagrams
classDiagram
GeoMapping.cshtml --> Microsoft.Maps.Map : creates
Microsoft.Maps.Map --> Pushpin : adds
Pushpin --> Infobox : displays
BingMapsAPI <|-- GeoMapping.cshtml : uses
GeoMapping.cshtml ..> Syncfusion.EJ2.TreeGrid : binds
GeoLocation <|-- TreeGrid : dataSource
GeoMapping.cshtml --> navigator.geolocation : tracks
Sequence Overview
sequenceDiagram
participant User
participant Browser
participant BingMapsAPI
participant ServerAPI
User->>Browser: Load GeoMapping.cshtml
Browser->>BingMapsAPI: GetMap()
Browser->>ServerAPI: fetch /Location/GetLocations
ServerAPI-->>Browser: JSON locations
Browser->>BingMapsAPI: draw Pushpins & infoboxes
User->>Browser: click pushpin
Browser->>Infobox: showInfobox()
10. Conclusion & Next Steps
GeoMapping.cshtml offers a rich interactive interface for legal and property teams to visualize and manage lease data.
Next Steps:
- š Secure your Bing Maps key in configuration
- š Extend directions and routing features
- š Internationalize: support alternate map locales
- š Add analytics: heatmaps, clustering
Happy mapping! šŗļøš