ProRank SEO

KML Sitemaps

Generate Google-compatible KML sitemaps for enhanced local search visibility and map integration

Live KML Generation: Your KML sitemap is automatically generated at/locations.kml and updates in real-time as you modify locations.

What is a KML Sitemap?

KML (Keyhole Markup Language) is an XML format used to display geographic data in mapping applications like Google Maps and Google Earth. A KML sitemap helps search engines understand your physical business locations and can improve your visibility in local search results and map packs.

Benefits of KML Sitemaps

  • Enhanced Google Maps visibility
  • Better local pack rankings
  • Improved "near me" searches
  • Direct Google My Business integration
  • Multi-location support
  • Automatic updates

Enabling KML Sitemap

Follow these steps to enable and configure your KML sitemap:

  1. Navigate to ProRank SEO → Local SEO → Schema & Settings
  2. Scroll to the KML Sitemap section
  3. Check "Enable KML Sitemap"
  4. Click "Save Settings"
  5. Your KML sitemap is now available at:
    https://yourdomain.com/locations.kml
The KML sitemap URL is automatically added to your robots.txt and can be submitted to Google Search Console.

Technical Implementation

The KML sitemap is implemented using WordPress rewrite rules and custom output handling:

// URL Rewrite Registration (LocalSeoMultiLocation.php)
public function register_kml_rewrite() {
    add_rewrite_rule('^locations.kml$', 'index.php?prorank_kml=1', 'top');
    add_rewrite_tag('%prorank_kml%', '([^&]+)');
}

// Request Handler
public function handle_kml_request() {
    if (get_query_var('prorank_kml')) {
        $settings = get_option('prorank_local_seo_settings', []);
        
        // Check if KML sitemap is enabled
        if (empty($settings['enable_kml_sitemap'])) {
            wp_die('KML sitemap is disabled', 'Not Found', ['response' => 404]);
        }
        
        $this->output_kml_sitemap();
        exit;
    }
}
After enabling KML sitemaps, you may need to flush permalinks by visiting Settings → Permalinks and clicking Save.

KML Output Format

The generated KML follows Google's specifications for business locations:

<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
  <Document>
    <name>Your Business Locations</name>
    <description>Business locations for Your Business</description>
    
    <Placemark>
      <name>Downtown Store</name>
      <description>
        123 Main St, New York, NY 10001
        Phone: +1-555-0100
        Website: https://example.com/downtown
      </description>
      <Point>
        <coordinates>-74.0060,40.7128,0</coordinates>
      </Point>
    </Placemark>
    
    <Placemark>
      <name>Uptown Branch</name>
      <description>
        456 Park Ave, New York, NY 10021
        Phone: +1-555-0200
        Website: https://example.com/uptown
      </description>
      <Point>
        <coordinates>-73.9665,40.7681,0</coordinates>
      </Point>
    </Placemark>
    
  </Document>
</kml>

Format Requirements

  • • Coordinates format: longitude,latitude,altitude
  • • Content-Type: application/vnd.google-earth.kml+xml
  • • Character encoding: UTF-8
  • • Valid XML structure with proper escaping

Location Requirements

For a location to appear in the KML sitemap, it must have:

Required Fields

  • Latitude: Valid decimal latitude (-90 to 90)
    Example: 40.7128
  • Longitude: Valid decimal longitude (-180 to 180)
    Example: -74.0060
  • Location Name: Unique identifier for the location
    Example: "Downtown Store"

Optional but Recommended

  • • Complete street address
  • • Phone number with country code
  • • Location-specific website URL
  • • Business hours
Locations without valid coordinates will be excluded from the KML sitemap but will still appear in schema markup and the locations manager.

Submitting to Google

Once your KML sitemap is generated, submit it to Google for indexing:

1. Google Search Console

  1. Open Google Search Console
  2. Go to Sitemaps section
  3. Enter: locations.kml
  4. Click Submit

2. Google My Business

  1. Sign in to Google My Business
  2. Select your business
  3. Go to InfoAdvanced Information
  4. Add your KML sitemap URL

3. Robots.txt (Automatic)

The plugin automatically adds your KML sitemap to robots.txt:

Sitemap: https://yourdomain.com/locations.kml

Validation & Testing

Verify your KML sitemap is working correctly:

Browser Test

Visit your KML URL directly:

https://yourdomain.com/locations.kml

You should see XML output with your locations.

Google Maps Test

Import into Google My Maps:

  1. Open Google My Maps
  2. Create new map
  3. Import → paste KML URL
  4. Verify locations appear
Use Google's Rich Results Test to validate the structured data associated with your locations.

Dynamic Updates

The KML sitemap updates automatically when you:

  • Add a new location with coordinates
  • Update location coordinates or address
  • Delete a location
  • Change location visibility settings
  • Modify primary location designation
// Automatic cache clearing on location update
public function clear_kml_cache() {
    // Clear any cached KML data
    delete_transient('prorank_kml_output');
    
    // Trigger sitemap ping to Google
    $this->ping_search_engines();
}

No manual regeneration needed - changes are reflected immediately in the KML output.

Troubleshooting

Common Issues

404 Error on KML URL

Solution: Flush permalinks by visiting Settings → Permalinks and clicking Save.

Empty KML File

Solution: Ensure at least one location has valid latitude and longitude coordinates.

Invalid XML Error

Solution: Check for special characters in location names/descriptions. All content is automatically escaped with esc_xml().

Not Showing in Google

Solution: Allow 24-48 hours for indexing. Check Search Console for crawl errors.

Best Practices

✅ Do

  • • Add coordinates for all locations
  • • Use accurate, verified coordinates
  • • Include complete address info
  • • Submit to Search Console
  • • Monitor for crawl errors

❌ Don't

  • • Use approximate coordinates
  • • Include closed locations
  • • Duplicate location entries
  • • Forget to update when moving
  • • Block KML in robots.txt