How to use google map street view api on webpage

In this article, you will learn to display street view on google map. Street view map is more clear to see the area than aerial view. This is more familiar and ideal for visitors. The Google Maps Embed API allows us to display street view on the web page with an interactive 360-degree panorama viewer, same as you see in the Street view on the google map. We can embed this service in our programming through the Maps JavaScript API which allows you to programmatically retrieve and display Street View photo spheres.

How to show street view on the google map

These are the following steps to show the street view on google map.

1. Get your api key

For showing google map in webpage, we need to generate Google API. For this, first login to your gmail account, go to 'Google API Console' and follow the instructions and get API key.

2. Create an HTML page and load the Google Map Javascript API into your web page.

To show Street view on the map, we will create an object literal and set properties by using google.maps.StreetViewPanorama constructor.

<!DOCTYPE html>
    <meta charset="utf-8">
    <title>Map Street View</title>
      html, body {
        height: 100%;
        margin: 0;
        padding: 0;
      #map_container, #streetview {
        float: left;
        height: 100%;
        width: 45%;
    <div id="map_container"></div>
    <div id="streetview"></div>
      function initialize() {
        var fenway = {lat: 28.6139, lng: 77.2091};
        var map = new google.maps.Map(document.getElementById('map_container'), {
          center: fenway,
          zoom: 10
        var panorama = new google.maps.StreetViewPanorama(
            document.getElementById('streetview'), {
              position: fenway,
              pov: {
                heading: 34,
                pitch: 10
    <script async defer

In the above example, replace the API_KEY with your generated API key. This script calls the google javascript map api, and callback parameter calls initialize function. The javascript function initialize() adds the map within the div element.


Related Articles

Driving route directions from source to destination using HTML5 and Javascript
How to add google map on your website with marker
How to add multiple custom markers on google map
Create pie chart using google api
Driving route directions from source to destination using HTML5 and Javascript
Calculate the distance between two locations using PHP
Simple star rating system using PHP, jQuery and Ajax

Read more articles

General Knowledge

Learn Popular Language