Maps: How can I use the latitude and longitude form fields to position the map markers?

The Maps Premium View (or the Map widget and the Entry Map field) requires to setup an address form field as the source to geocode the map markers. That Address field is by default a standard Gravity Forms address field type. You may use  a different field type as the address source.

If you have the position coordinates (latitude and longitude) stored as form fields, you may also use them instead of the Address to position the markers over the map.

A form, with three Gravity Forms text fields. One labelled Latitude, one Longitude, and the final labelled Map Icon.

This is how these fields will look to the user (with some values filled-in):

The form, with longitude and latitude values filled in, and a custom map icon of a green flag picked.

When using the Maps Premium View extension, in order to override the Address Field setting replacing it by the coordinates fields, you can use the filter  gravityview/maps/markers/lat_long/fields_id to use the passed longitude and latitude as the coordinates for the entry.

Then when the map is rendered, the coordinates will be pulled from the Longitude and Latitude fields:

Map showing the marker placed in Cape Canaveral, Florida (the city that the coordinates referred to)

In the form shown above in this article, the form ID is "46", the Latitude field ID is "6" and the Longitude field ID is "7", so we would use the following code:

Modify the code below for your own site

Modify the code below with your own form ID, longitude field ID and latitude field id:

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.

Still need help? Contact Us Contact Us