Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using KMZ Files in Google Maps

Is there any way I can use a KMZ file in Google Maps? My KML file is around 10.7MB so it doesn't load on Google Maps. KMZ file is around 2MB. The only way I see it is to have multiple KML but it's too much work. I might end up doing that, but was just wondering if KMZ can be used?

Thanks.

like image 628
kaoscify Avatar asked Mar 21 '12 18:03

kaoscify


People also ask

Can I use a KMZ file in Google Maps?

kmz (Zipped KML format) file in your browser. Free online tool to view KML, KMZ files from the web on a Google map. You can open KML, KMZ files from URL, Google Drive or from your computer.

What is the difference between a KMZ and a KML?

KML can include both raster and vector data, and the file includes symbolization. KML files are like HTML, and only contains links to icons and raster layers. A KMZ file combines the images with the KML into a single zipped file.

How do I use KMZ?

The Google Earth Pro desktop application is a common choice for opening KMZ files. To open a KMZ file with Google Earth Pro, select File → Open.... You can also open a KMZ file in Google Maps by saving the KMZ file to an online location and then typing the URL in the Google Maps search box.


1 Answers

Yes, you can specify a KMZ file using the Maps API:

var kmzLayer = new google.maps.KmlLayer('http://www.kmzlinks.com/redirect.asp?id=110&file=PalmIsland%2Ekmz');
kmzLayer.setMap(map);

In your specific case, your script should look like this:

<script type="text/javascript">
  function initialize() {
    var myOptions = {
      center: new google.maps.LatLng(58.33, -98.52),
      zoom: 11,
      mapTypeId: google.maps.MapTypeId.ROADMAP
    };
    var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
    var kmzLayer = new google.maps.KmlLayer('http://xeenat.com/energy/data.kmz');
    kmzLayer.setMap(map);
  }
</script>

BUT - your KML is too big. Even though it's compressed down to 2MB as a KMZ, Maps looks at the size after it's been decompressed, and in your case that's bigger than 10MB. Try cutting it down a bit - if you replace your KMZ URL with the one in the first snippet above, it will work. Looks like you'll need to use multiple KML files. Perhaps you could load the KMZ into Google Earth, then save each province as its own file (right-click on the folder in Earth's "Places" tab, and select Save as...)

like image 100
Mike Jeffrey Avatar answered Sep 22 '22 03:09

Mike Jeffrey