3

I just need to return the latitude and longitude of my Google Maps marker. I do not want to make a request to Google, nor do I need to display a map with javascript. I need to create markers inside of blog entries and only return the coordinates.

Can the Google Maps plugin do this? Can I pass the lat and lng to text fields when i save the entry?

4

Was out of town so couldn't answer this question until now. With Google Maps for Craft you can do so like this:

{% set marker = entry.yourMapField.getMarker(0) %}

{{ marker.lat }} {{ marker.lng }}

Or you can loop through all the markers on the map like this:

{% for entry in craft.entries.section('news') %}

    {% for marker in entry.yourMapField.getMarkers() %}

        {{ marker.address }}<br>

    {% endfor %}

{% endfor %}

https://github.com/objectivehtml/Google-Maps-for-Craft/wiki/Getting-Address-From-Map-Markers

3

I don’t know about ObjectiveHTML’s Google Maps plugin, but this is easy to do using Lindsey DiLoreto’s Smart Map plugin, which comes with an “Address” field type.

Per the “Using an Address Field” documentation, you can output latitude and longitude values like this:

Latitude: {{ entry.address.lat }}<br />
Longitude: {{ entry.address.lng }}

(In that example, entry is an entry that has an Address field called address.)

  • 1
    Just used Smart Map, the best plugin IMO out there to manage maps. – Jason Mayo Jun 30 '15 at 22:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.