Whether you are working with dynamic maps or static maps, you'll need to specify the locations that you want to appear on the map. You'll most often encounter this parameter when you create a map or add markers to a map.

What are "locations"? They can be any of the following...

# Coordinates

The locations value can be a set of coordinates, or an array of coordinate sets.

// As a single set of coordinates
var locations = {
    'lat':  32.3113966,
    'lng': -64.7527469

// As an array of coordinate sets
var locations = [
    {'lat': 37.2430548, 'lng': -115.7930198},
    {'lat': 57.3009274, 'lng':   -4.4496567}

In JavaScript, you may only use Coordinates

If you are working in JavaScript, then your only option is to work with coordinates. It is physically impossible to translate Address Models and Elements into JavaScript.

# Address Models

The locations value can be set as an individual Address Model, or as an array of Address Models.

{# As a single Address Model #}
{% set locations = entry.myAddressField %}

{# As an array of Address Models #}
{% set locations = [
] %}

# Elements

The locations value can be set as an individual Element (opens new window), or as an array (or collection) of Elements. This can include any native Element Types (ie: Entries, Categories, Users, etc), as well as any custom Element Types introduced by other plugins or modules.

{# As a single Element #}
{% set locations = entry %}

{# As an array of Elements #}
{% set locations = craft.entries.all() %}

{# As a collection of Elements #}
{% set locations = craft.entries.collect() %}

Elements must have a valid Address field

When using an Element, ensure that it has at least one Address field attached to it. The plugin will automatically render each valid Address field on the map.