---
title: "Using a latitude and longitude fields to position the map markers"
date: 2026-04-23
author: "GravityKit"
link: "https://www.gravitykit.com/docs/gravityview-pro/maps-premium-view/how-can-i-use-the-latitude-and-longitude-form-fields-to-position-map-markers/"
---

The Maps layout (or the Multiple Entries Map widget and the Entry Map field) requires an address field on your form, which will be used as a source to geocode the coordinates to create 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](https://www.gravitykit.com/docs/gravityview-pro/maps-premium-view/how-can-i-pull-the-address-from-a-field-type-that-is-not-address/).

If you have the position coordinates (latitude and longitude) stored as two separate form fields, you may use them instead of the Address field 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.](https://www.gravitykit.com/wp-content/uploads/2026/04/nefOpf.png)
*If you wish to replace the Address field with a Latitude and a Longitude fields, these are the filters you'll need depending on which version of the Maps plugin you are using:*

### For GravityView Maps plugin version 3.1 and newer:

```
add_filter( 'gk/gravitymaps/markers/coordinates/fields-ids', static function( $fields_array = [], $view = null ) {	$form = $view->form->form;	/** Only use these fields if the form ID is 46 */	if ( 46 !== (int) $form['id'] ) {		return $fields_array;	}                /** IDs of the Latitude and Longitude fields */        return [ '3', '4' ];}, 10, 2 );
```

```
add_filter( 'gk/gravitymaps/markers/coordinates/fields-ids', static function( $fields_array = [], $view = null ) {	$form = $view->form->form;	/** Only use these fields if the form ID is 46 */	if ( 46 !== (int) $form['id'] ) {		return $fields_array;	}                /** IDs of the Latitude and Longitude fields */        return [ '3', '4' ];}, 10, 2 );
```

### For GravityView Maps plugin versions 3.0.x and older:

```
add_filter( 'gravityview/maps/markers/lat_long/fields_id', 'gk_lat_long_fields', 10, 2 );function gk_lat_long_fields( $fields_array = array(), $gravityview_view = null ) {	$form = $gravityview_view->getForm();        /** Only use these fields if the form ID is 46 */	if ( 46 !== (int) $form['id'] ) {		return $fields_array;	}        /** IDs of the Latitude and Longitude fields */	return array( '6', '7' ); }
```

```
add_filter( 'gravityview/maps/markers/lat_long/fields_id', 'gk_lat_long_fields', 10, 2 );function gk_lat_long_fields( $fields_array = array(), $gravityview_view = null ) {	$form = $gravityview_view->getForm();        /** Only use these fields if the form ID is 46 */	if ( 46 !== (int) $form['id'] ) {		return $fields_array;	}        /** IDs of the Latitude and Longitude fields */	return array( '6', '7' ); }
```

Here's an example that specifies different field IDs depending on which form is being called:

```
add_filter( 'gravityview/maps/markers/lat_long/fields_id', 'gk_maps_lat_long_fields', 10, 2 );function gk_maps_lat_long_fields( $fields_array = array(), $gravityview_view = null ) {	$form = $gravityview_view->form->form;	$formid = (int) $form['id'];		switch ($formid) {	    case 41: /** To use with form ID = 41 */	        return array( '1', '2' );	        break;	    case 42: /** To use with form ID = 42 */	        return array( '3', '4' );	        break;	    case 43: /** To use with form ID = 43 */	        return array( '6', '7' );	        break;	    default:	       return $fields_array;	}}
```

```
add_filter( 'gravityview/maps/markers/lat_long/fields_id', 'gk_maps_lat_long_fields', 10, 2 );function gk_maps_lat_long_fields( $fields_array = array(), $gravityview_view = null ) {	$form = $gravityview_view->form->form;	$formid = (int) $form['id'];		switch ($formid) {	    case 41: /** To use with form ID = 41 */	        return array( '1', '2' );	        break;	    case 42: /** To use with form ID = 42 */	        return array( '3', '4' );	        break;	    case 43: /** To use with form ID = 43 */	        return array( '6', '7' );	        break;	    default:	       return $fields_array;	}}
```

Read here how to add these code samples to your website: [Where to put code samples.](https://www.gravitykit.com/docs/gravityview/customizing-your-views/where-to-put-code-samples/)