KML Sitemaps
Generate Google-compatible KML sitemaps for enhanced local search visibility and map integration
/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:
- Navigate to ProRank SEO → Local SEO → Schema & Settings
- Scroll to the KML Sitemap section
- Check "Enable KML Sitemap"
- Click "Save Settings"
- Your KML sitemap is now available at:
https://yourdomain.com/locations.kml
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;
}
}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 locationExample: "Downtown Store"
Optional but Recommended
- • Complete street address
- • Phone number with country code
- • Location-specific website URL
- • Business hours
Submitting to Google
Once your KML sitemap is generated, submit it to Google for indexing:
1. Google Search Console
- Open Google Search Console
- Go to Sitemaps section
- Enter:
locations.kml - Click Submit
2. Google My Business
- Sign in to Google My Business
- Select your business
- Go to Info → Advanced Information
- Add your KML sitemap URL
3. Robots.txt (Automatic)
The plugin automatically adds your KML sitemap to robots.txt:
Sitemap: https://yourdomain.com/locations.kmlValidation & Testing
Verify your KML sitemap is working correctly:
Browser Test
Visit your KML URL directly:
https://yourdomain.com/locations.kmlYou should see XML output with your locations.
Google Maps Test
Import into Google My Maps:
- Open Google My Maps
- Create new map
- Import → paste KML URL
- Verify locations appear
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