Using the Field Type
objectivehtml edited this page Sep 11, 2014
·
3 revisions
Using the field type to add data to a map is pretty straight forward. The field type returns a GoogleMaps_MapDataModel
object which is then passed to a craft.googleMaps.data()
method. The data is extrapolated and passed into the browser where it is rendered with JavaScript. In this example yourMapField
is the name of the Google Maps field, and news
is the section. map
is the map's id and also the name of the global JS variable with the map instance.
{% set options = {
id: 'map',
width: '400px',
height: '300px'
} %}
{{ craft.googleMaps.map(options) }}
{% for entry in craft.entries.section('news') %}
{{ craft.googleMaps.data('map', entry.yourMapField) }}
{% endfor %}