Skip to content

Instantly share code, notes, and snippets.

@mhulse
Created August 25, 2011 20:47
Show Gist options
  • Select an option

  • Save mhulse/1171871 to your computer and use it in GitHub Desktop.

Select an option

Save mhulse/1171871 to your computer and use it in GitHub Desktop.
Google Maps v3: Load KML Layer...
/* Show map until loaded?
http://groups.google.com/group/google-maps-js-api-v3/msg/a9dda851790a6c54
*/
function showCrossHair(divId) {
var mmap = document.getElementById(divId);
var div = document.createElement('div');
div.id = 'crossHair';
div.style.position = 'absolute';
div.style.padding = '0';
div.style.marginLeft = '-10px';
div.style.marginTop = '-10px';
div.style.left = '50%';
div.style.top = '50%';
div.style.zIndex = '5000';
div.innerHTML = '<img src="images/crosshair.gif">';
div.innerHTML = div.innerHTML;
crossHairDiv = div;
mmap.appendChild(div);
};
function initialize() {
var myLatlng = new google.maps.LatLng(42.0737, -122.603);
var myOptions = {
zoom: 8,
center: myLatlng,
mapTypeId: google.maps.MapTypeId.TERRAIN
}
var map = new google.maps.Map(document.getElementById('map'), myOptions);
showCrossHair('map');
var l1 = new google.maps.KmlLayer('http://pipes.yahoo.com/pipes/pipe.run?_id=6f14a71211b7bb457b2ea68e0a3f7d86&_render=kml&glId=0SoN98QN3nRbQAxn6YLoXTP5qpqv8PYxu&mode=latestOnly'); // , { preserveViewport: true }
l1.setMap(map);
google.maps.event.addListenerOnce(l1, 'defaultviewport_changed', function() {
center = l1.getDefaultViewport().getCenter();
map.panTo(center);
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment