Skip to content

Latest commit

 

History

History
72 lines (48 loc) · 1.69 KB

File metadata and controls

72 lines (48 loc) · 1.69 KB

Map

Build

First of all, if you want to render a map, you will need to build one:

use Ivory\GoogleMap\Map;

$map = new Map();

Then, you can manipulate it as explained in the library documentation.

Configuration

You can configure some global options related to the API in order to update its behavior. Be aware these options are shared with the Place autocomplete.

Debug

The debug option allows to get a nicely formatted output instead of the default output optimized for production:

ivory_google_map:
    map:
        debug: "%kernel.debug%"

Language

The language allows you to configure your map language:

ivory_google_map:
    map:
        language: "%locale%"

API key

The API key allows you to bypass Google limitation according to your account plan:

ivory_google_map:
    map:
        api_key: ~

Render

Once, your map is ready to be rendered, you should rely on the built-in helpers allowing you to easily render your map according to your templating engine.

Twig

If you're using Twig, the most easy way to render a map is:

{{ ivory_google_map(map) }}
{{ ivory_google_api([map]) }}

The available Twig functions are:

  • ivory_google_api: Renders the Google API loading.
  • ivory_google_map: Renders the map container + javascript + stylesheet.
  • ivory_google_map_container: Renders the map container.
  • ivory_google_map_js: Renders the map javascript.
  • ivory_google_map_css: Renders the map stylesheet.

Don't forget to always render the Google API loading after rendering your map.