How to Add Google map on Your Website

How to Add Google map on Your Website

How to Add Google map on Your Website

0 Sales

Free

Google Map is the most direct choice to show a guide on the site page. Google Map is the for the most part used segment for a site and you can without a lot of a stretch add Google Map to your site. This instructional exercise discloses to you the most ideal approach to add Google Map with marker to site inside 5 minutes.

The model code will embed Google map in the site and point a region with a marker. Also, an orientation association will be given on the guide that empowers customers to get the course of the foreordained region. We'll use the Google Maps JavaScript API for indicating the guide with your optimal region mark on it.

Get Latitude and Longitude

From the beginning, you need to get the extension and longitude of your optimal territory. Seek after the underneath steps to get the extension and longitude from the Google Map.

1. Visit the Google Maps site.

2. Enter your optimal region and search.

3. Engraving the cautious territory on Google Map. A marker will appear on your checked zone and besides a talk box will appear at the base of the guide.

4. In this talk box, you'll see the nuances address, degree, and longitude. Assemble the extension and longitude from the base of the talk box.

 

Get API Key from Google Developer Console

Google Maps JavaScript API requires an API Key to stack. All requesting to Google Maps JavaScript API must consolidate as the estimation of the key parameter. Thusly, before you start, make a free API key on Google Developer Console. If you are an amateur on Google map, see the join a tiny bit at a time manual for get API key from Google API Console.

If you are not content with coding, the Google Map code can be delivered online without having the coding data. Use this online free instrument to re-try and addition Google manual for the website – Online Free Google Map Embed Code Generator

Detect the going with code into your site page HTML where you need to consolidate the Google Map.

 

JavaScript Code

From the beginning, load the Google Maps JavaScript API and give your API Key in key parameter.

<script src="https://maps.googleapis.com/maps/api/js?key=Your_API_KEY"></script>

 

Detect the going with JavaScript to incorporate a guide with a marker using Google Maps JavaScript API. You need to decide your zone's degree and longitude into the LatLng() procedure.

<script>
var myCenter = new google.maps.LatLng(37.422230, -122.084058);
function initialize(){
    var mapProp = {
        center:myCenter,
        zoom:12,
        mapTypeId:google.maps.MapTypeId.ROADMAP
    };

    var map = new google.maps.Map(document.getElementById("map"),mapProp);

    var marker = new google.maps.Marker({
        position:myCenter,
    });

    marker.setMap(map);
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>

 

HTMLCode

Portray a zone in the site page to show the Google Map. This district selector (map) ought to be resolved in Map JavaScript Object.

<div id="map"></div>

If you have to incorporate a direction association over the Google map, the HTML ought to be modified with the stay interface. In like manner, you need to demonstrate the extension and longitude in the hyperlink.

<div class="mapContainer">
    <a class="direction-link" target="_blank" href="//maps.google.com/maps?f=d&amp;daddr=37.422230,-122.084058&amp;hl=en"> Get Directions</a>
    <div id="map"></div>
</div>

 

CSS Code

Add the going with CSS to set the width and stature of the Google map.

#map{
    width: 100%;
    height: 400px;
}

If you incorporated the heading join, use the going with CSS to styling the association, by and large, don't need to incorporate this CSS.

.mapContainer{
    width:50%;
    position: relative;
}
.mapContainer a.direction-link {
    position: absolute;
    top: 15px;
    right: 15px;
    z-index: 100010;
    color: #FFF;
    text-decoration: none;
    font-size: 15px;
    font-weight: bold;
    line-height: 25px;
    padding: 8px 20px 8px 50px;
    background: #0094de;
    background-image: url('direction-icon.png');
    background-position: left center;
    background-repeat: no-repeat;
}
.mapContainer a.direction-link:hover {
    text-decoration: none;
    background: #0072ab;
    color: #FFF;
    background-image: url('direction-icon.png');
    background-position: left center;
    background-repeat: no-repeat;
}

At the point when you set up all code together on your site page, the Google Map will appear with marker and course associate.

LICENSE OF USE

You can use it for personal or commercial projects. You can't resell it partially or in this form.

PRODUCT INFO

Create Date : Oct 24, 2019

Updated Date : Nov 16, 2019

Ratings

Comments : 0

Downloads : 0