Google Map Using Bootstrap In ASP.NET MVC - Part Two

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
  1. Compass wheel around the Pan control, which allows you to rotate the image.
  2. Rotate control between the Pan and Zoom controls, which allows you to rotate the image 90°.
  3. 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.  
  1. using System;  
  2. using System.Collections.Generic;  
  3. using System.Linq;  
  4. using System.Web;  
  5. using System.Web.Mvc;  
  6.   
  7. namespace SatyaGoogleMapBootstrapMVC.Controllers  
  8. {  
  9.     public class HomeController : Controller  
  10.     {  
  11.         //  
  12.         // GET: /Home/  
  13.   
  14.         public ActionResult Index()  
  15.         {  
  16.             return View();  
  17.         }  
  18.         public ActionResult Details()  
  19.         {  
  20.             return View();  
  21.         }  
  22.   
  23.     }  

Now, create a view named Details.cshtml.
  1. @{  
  2.     ViewBag.Title = "Satyaprakash Bhubaneswar Details Google Map";  
  3. }  
  4.   
  5. <title>@ViewBag.Title</title>  
  6.   
  7. <h2 style="background-color: Yellow;color: Blue; text-align: center; font-style: oblique">Satyaprakash's Bhubaneswar City Details Using MVC and BOOTSTRAP</h2>  
  8. <fieldset>  
  9.     <legend style="font-family: Arial Black; color: blue; font-size: large;">Check Bhubaneswar City Details</legend>  
  10.     <meta charset="utf-8">  
  11.     <meta name="viewport" content="width=device-width, initial-scale=1">  
  12.     <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">  
  13.     <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>  
  14.     <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>  
  15.   
  16.     <div id="map" style="width:100%;height:500px"></div>  
  17.     <script>  
  18.         function myMap() {  
  19.             var mapCanvas = document.getElementById("map");  
  20.             var mapOptions = {  
  21.                 center: new google.maps.LatLng(20.296100, 85.824500),  
  22.                 zoom: 18,  
  23.                 mapTypeId: google.maps.MapTypeId.HYBRID  
  24.             };  
  25.             var map = new google.maps.Map(mapCanvas, mapOptions);  
  26.         }  
  27.     </script>  
  28.   
  29.     <script src="https://maps.googleapis.com/maps/api/js?key=Put_Your_Own_Api_Here8&callback=myMap"></script>  
  30.   
  31. </fieldset>  
  32. <footer>  
  33.     <p style="background-color: Yellow; font-weight: bold; color:blue; text-align: center; font-style: oblique">© @DateTime.Now.ToLocalTime()</p> @*Add Date Time*@  
  34. </footer> 
 Here, I used Map type "HYBRID". This type will show photographic map + roads and city names.
  1. 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
  1. How to add Google map types In MVC.
  2. Get city details like Town, Street, Restaurants, Colleges inside town.
  3. Popup to know the details.