Introduction
Before going through this blog, read Google Map, using Bootstrap in ASP.NET MVC Part-1 carefully.
http://www.c-sharpcorner.com/blogs/google-map-using-bootstrap-in-asp-net-mvc-part1
Description
The map types given below are supported in Google Maps API
ROADMAP - This type will show normal, default 2D map.
SATELLITE- This type will show photographic maps.
HYBRID- This type will show photographic maps + roads and city names.
TERRAIN- This type will show maps with mountains, rivers etc.
The map type is specified either within the Map properties object, with the mapTypeId property or by calling the map's setMapTypeId() method.
The map types SATELLITE and HYBRID support a 45° perspective imagery view for the certain locations and
not for all the locations only at high zoom levels.
If you zoom into a location with 45° imagery view, the map will automatically alter the perspective view.
The map will add
- Compass wheel around the Pan control, which allows you to rotate the image.
- Rotate control between the Pan and Zoom controls, which allows you to rotate the image 90°.
- Toggle control to display the 45° perspective view under the Satellite control/label.
Zooming out from a map with 45° imagery will revert each of these changes and the original map is displayed.
Steps
Create a Controller action method named Details() in the same controller HomeController.cs of this same MVC Application.
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Web.Mvc;
-
- namespace SatyaGoogleMapBootstrapMVC.Controllers
- {
- public class HomeController : Controller
- {
-
-
-
- public ActionResult Index()
- {
- return View();
- }
- public ActionResult Details()
- {
- return View();
- }
-
- }
- }
Now, create a view named Details.cshtml.
- @{
- ViewBag.Title = "Satyaprakash Bhubaneswar Details Google Map";
- }
-
- <title>@ViewBag.Title</title>
-
- <h2 style="background-color: Yellow;color: Blue; text-align: center; font-style: oblique">Satyaprakash's Bhubaneswar City Details Using MVC and BOOTSTRAP</h2>
- <fieldset>
- <legend style="font-family: Arial Black; color: blue; font-size: large;">Check Bhubaneswar City Details</legend>
- <meta charset="utf-8">
- <meta name="viewport" content="width=device-width, initial-scale=1">
- <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
- <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
- <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
-
- <div id="map" style="width:100%;height:500px"></div>
- <script>
- function myMap() {
- var mapCanvas = document.getElementById("map");
- var mapOptions = {
- center: new google.maps.LatLng(20.296100, 85.824500),
- zoom: 18,
- mapTypeId: google.maps.MapTypeId.HYBRID
- };
- var map = new google.maps.Map(mapCanvas, mapOptions);
- }
- </script>
-
- <script src="https://maps.googleapis.com/maps/api/js?key=Put_Your_Own_Api_Here8&callback=myMap"></script>
-
- </fieldset>
- <footer>
- <p style="background-color: Yellow; font-weight: bold; color:blue; text-align: center; font-style: oblique">© @DateTime.Now.ToLocalTime()</p> @*Add Date Time*@
- </footer>
Here, I used Map type "HYBRID". This type will show photographic map + roads and city names.
- mapTypeId: google.maps.MapTypeId.HYBRID
The other parts descriptions are same as in Part-1.
Output Places inside Bhubaneswar city
URL: http://localhost:57237/Home/Details
Desktop view
Place PopUp
Mobile view
Summary
- How to add Google map types In MVC.
- Get city details like Town, Street, Restaurants, Colleges inside town.
- Popup to know the details.