Skip to content

Instantly share code, notes, and snippets.

@michalsn
Created June 8, 2014 17:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save michalsn/4196517ed44b1d4b7f93 to your computer and use it in GitHub Desktop.
Save michalsn/4196517ed44b1d4b7f93 to your computer and use it in GitHub Desktop.
Load KML file using geoxml3
<kml xmlns="http://www.opengis.net/kml/2.2">
<Document>
<?php foreach ($suburbs as $suburb): ?>
<Placemark>
<name><?php echo $suburb->suburb; ?></name>
<?php echo $suburb->geometry; ?>
</Placemark>
<?php endforeach; ?>
</Document>
</kml>
<script type="text/javascript" src="<?php echo base_url('js/geoxml3.js'); ?>"></script>
<script type="text/javascript" src="https://maps-api-ssl.google.com/maps/api/js?sensor=false"></script>
<script type="text/javascript">
var geoXml, map = null;
function initialize() {
var mapOptions = {
zoom: 11
}
map = new google.maps.Map(document.getElementById('map_canvas'), mapOptions);
geoXml = new geoXML3.parser({
map: map
});
geoXml.parse('<?php echo site_url("url/to/kml/file"); ?>');
}
$(function() {
google.maps.event.addDomListener(window, 'load', initialize);
});
</script>
<div id="map_canvas" style="width:100%; height: 600px;"></div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment