Get path using the user's location to the default Marker (javascript google-mapsv3)

0

I am using the answer that is in the question of the following link: question

And I do not understand what I need to put in the line below where the comment is:

map = new google.maps.Map( /*creates Map variable*/ document.getElementById("map"), mapOptions /*Creates a new map using the passed optional parameters in the mapOptions parameter.*/);
    
asked by anonymous 18.05.2016 / 16:46

1 answer

1
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 with the id of your div.

mapOptions 

This is an object with the map options that you are going to create, it will pass the object you created earlier 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 of your map. Without the comments would just be:

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

The example is only commenting on what each information is. You just need to pass the correct div and object with the settings you need.

    
18.05.2016 / 21:08