简体   繁体   中英

Input arguments to a JavaScript inline function

I'm reading this example snippet in googlemaps API.


The below is an extract from the snippet.

getNormalizedCoord(coord, zoom) is a separately defined function.

The value of the getTileUrl attribute is assigned to the output of the inline function which takes (coord, zoom) as arguements.

var moonMapType = new google.maps.ImageMapType({

     getTileUrl: function(coord, zoom) {
            var normalizedCoord = getNormalizedCoord(coord, zoom);
            ....
            ....
     },
     ....
     ....
});

Question: What are the values of the coord, zoom variables when they are called inside the inline function?

I don't see them assigned to anything prior to calling them.

It's taking the parameters from getTileUrl which belongs to the ImageMapTypeOptions object specification.

getTileUrl  
Type:  function(Point, number): string
Returns a string (URL) for given tile coordinate (x, y) and zoom level.

https://developers.google.com/maps/documentation/javascript/3.exp/reference#ImageMapTypeOptions

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM