
// ---------------------------------------------------------------------------
// Google Aerial View API -- building page flyover video (2026-08-09).
// Requires the NESTAPPLE_AERIAL_VIEW_API_KEY constant to be defined in
// wp-config.php (a Google Cloud API key with the Aerial View API enabled
// and billing configured -- not provisioned here, this site has none yet).
// Google's own docs state "receiving a video is a billable event" -- each
// lookup call costs money -- so results are cached via transient to avoid
// re-billing on every single page view. Coverage is real US addresses only;
// gracefully returns null (caller falls back to the existing static map)
// for unsupported addresses, missing key, or any API error -- never fatals.
// ---------------------------------------------------------------------------
function nestapple_get_aerial_view_video( $address ) {
	if ( ! defined( 'NESTAPPLE_AERIAL_VIEW_API_KEY' ) || ! NESTAPPLE_AERIAL_VIEW_API_KEY || ! $address ) {
		return null;
	}
	$cache_key = 'aerial_view_' . md5( $address );
	$cached = get_transient( $cache_key );
	if ( false !== $cached ) {
		return $cached ?: null; // cached null (no coverage) is stored as empty string, see below
	}

	$url = add_query_arg( array(
		'address' => rawurlencode( $address ),
		'key'     => NESTAPPLE_AERIAL_VIEW_API_KEY,
	), 'https://aerialview.googleapis.com/v1/videos:lookupVideo' );

	$response = wp_remote_get( $url, array( 'timeout' => 8 ) );
	if ( is_wp_error( $response ) || 200 !== wp_remote_retrieve_response_code( $response ) ) {
		set_transient( $cache_key, '', 20 * MINUTE_IN_SECONDS ); // cache the miss too, avoid hammering on errors
		return null;
	}
	$body = json_decode( wp_remote_retrieve_body( $response ), true );
	if ( empty( $body['state'] ) || 'ACTIVE' !== $body['state'] || empty( $body['uris'] ) ) {
		set_transient( $cache_key, '', 20 * MINUTE_IN_SECONDS );
		return null;
	}
	// Response uris map is keyed by aspect ratio (e.g. "16x9"); take the first available landscapeUri.
	$video_url = null;
	foreach ( $body['uris'] as $variant ) {
		if ( ! empty( $variant['landscapeUri'] ) ) {
			$video_url = $variant['landscapeUri'];
			break;
		}
	}
	// Google's URIs are signed and short-lived -- exact TTL isn't documented, so this
	// caches successful lookups conservatively short (5 min) to minimize the risk of
	// handing a visitor an expired link, while the negative case above (no coverage/
	// error) is cached longer since that state changes far less often.
	set_transient( $cache_key, $video_url ?: '', 5 * MINUTE_IN_SECONDS );
	return $video_url;
}
<?xml version="1.0" encoding="UTF-8"?><?xml-stylesheet type="text/xsl" href="//www.nestapple.com/wp-content/plugins/wordpress-seo/css/main-sitemap.xsl"?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
	<sitemap>
		<loc>https://www.nestapple.com/post-sitemap.xml</loc>
		<lastmod>2026-08-09T12:00:55+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://www.nestapple.com/page-sitemap.xml</loc>
		<lastmod>2026-08-09T19:00:05+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://www.nestapple.com/rls_listing-sitemap.xml</loc>
		<lastmod>2026-08-09T15:10:05+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://www.nestapple.com/rls_building-sitemap.xml</loc>
		<lastmod>2026-08-07T03:49:04+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://www.nestapple.com/category-sitemap.xml</loc>
		<lastmod>2026-08-09T12:00:55+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://www.nestapple.com/rls_neighborhood-sitemap.xml</loc>
		<lastmod>2026-08-09T15:10:05+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://www.nestapple.com/rls_status-sitemap.xml</loc>
		<lastmod>2026-08-09T15:10:05+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://www.nestapple.com/rls_property_type-sitemap.xml</loc>
		<lastmod>2026-08-09T15:10:05+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://www.nestapple.com/rls_amenity-sitemap.xml</loc>
		<lastmod>2026-08-09T15:10:05+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://www.nestapple.com/author-sitemap.xml</loc>
		<lastmod>2026-07-26T13:15:28+00:00</lastmod>
	</sitemap>
</sitemapindex>
<!-- XML Sitemap generated by Yoast SEO -->