Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Centering map and setting marker with dynamic fields #66

Open
iamtompickering opened this issue Aug 22, 2016 · 0 comments
Open

Centering map and setting marker with dynamic fields #66

iamtompickering opened this issue Aug 22, 2016 · 0 comments

Comments

@iamtompickering
Copy link

iamtompickering commented Aug 22, 2016

I'm trying to set the center of the map and a marker from some plain text fields in the entry but it doesn't seem to recognise the fields in the settings. When I replace the entry.locationLatitude and entry.locationLongitude with actual values it works fine, but these need to be dynamic per entry. Is this possible and if so please could you let me know how this can be done as I cannot find it anywhere in the documentation.

{% set options = {
    id: 'map', 
    width: '100%', 
    height: '250px',
} %}

{{ craft.googleMaps.map(options) }}

{% set marker = {
    id: 'map',
    data: {
        latitude: entry.locationLatitude,
        longitude: entry.locationLatitude
    }
} %}

{{ craft.googleMaps.center('map', entry.locationLatitude, entry.locationLongitude) }}
{{ craft.googleMaps.marker('map', marker) }}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant