You need to check to see if the lat
and lng
indexes are set on the field array. You do this using the isset()
PHP method. If they aren’t shown you can display an error (or nothing) and if they are then proceed with the rest of your code.
$location = get_field('map');
if ( isset( $location['lat'] ) && isset( $location['lng'] ) ){
$lat = $location['lat'];
$lng = $location['lng'];
$coords = $lat.".".$lng;
// ... the rest of your code
} else {
// ... the lat/lng location is not set
}