document.getElementById("map")
In this part of the code you put the id of the div where the map will be made, in this example the id of the div is "map". You can replace it with the id of your div.
mapOptions
This is an object with the map options you will create, will pass the object you previously created in the example
var mapOptions = //Sets map options
{
zoom: 15, //Sets zoom level (0-21)
center: coords, //zoom in on users location
mapTypeControl: true, //allows you to select map type eg. map or satellite
navigationControlOptions:
{
style: google.maps.NavigationControlStyle.SMALL //sets map controls size eg. zoom
},
mapTypeId: google.maps.MapTypeId.ROADMAP //sets type of map Options:ROADMAP, SATELLITE, HYBRID, TERRIAN
};
In this case you are setting the zoom, center and other settings on your map.
Without the comments would just be:
map = new google.maps.Map(document.getElementById("map"), mapOptions);
The example is only commenting on what is each information. Just need to pass the correct div and the object with the settings you need.
Thank you very much for the answer however on this line I am having the following error: js:1 Uncaught Typeerror: Cannot read Property 'offsetWidth' of null_.Kf @js:1qg @js:1(Anonymous Function) @ VM71:39 . The error was taken from the browser console
– HideCode
Is your div id correct? is the same as in getElementById?
– André Vicente
I really had Div’s name wrong. You solved my problem. Thank you
– HideCode