Created
February 2, 2011 20:52
-
-
Save trygvea/808405 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function ($) { | |
jQuery.noConflict(); | |
var sheepImage = new google.maps.MarkerImage('sau.png', | |
new google.maps.Size(37, 25), // marker size | |
new google.maps.Point(0,0), // origin | |
new google.maps.Point(18, 12)); // anchor is the middle of the image | |
var shape = { | |
coord: [1, 1, 1, 37, 25, 37, 25 , 1], | |
type: 'poly' | |
}; | |
var map; | |
/***************************************************************************** | |
* Temporarily, add dummy random sheep. Put in remote service later. | |
*/ | |
var addSheep = function(numSheep) { | |
var center = new google.maps.LatLng(59.918118, 10.736732); | |
for (i=1;i<=numSheep;i=i+1) { | |
var pos = new google.maps.LatLng(center.lat() + 0.05 * Math.random(), center.lng() + 0.3 * (Math.random()-0.5)); | |
addOneSheep(pos, i); | |
} | |
} | |
var addOneSheep = function(pos, sheepNo) { | |
var marker = new google.maps.Marker({ | |
position: pos, | |
shape: shape, | |
icon: sheepImage, | |
title: "Bring it on", | |
map: map | |
}); | |
var contentString = '<div id="content">'+ | |
'<div id="sau'+sheepNo+'">'+ | |
'</div>'+ | |
'<h1 id="firstHeading" class="firstHeading">Sau nr '+sheepNo+'</h1>'+ | |
'<div id="bodyContent">'+ | |
'<p><b>Info:</b>bææææææææææææ' + | |
'</div>'+ | |
'</div>'; | |
marker.setTitle("Sau nummer #"+sheepNo); | |
var infowindow = new google.maps.InfoWindow({ | |
content: contentString | |
}); | |
google.maps.event.addListener(marker, 'click', function() { | |
infowindow.open(map,marker); | |
}); | |
} | |
/***************************************************************************** | |
* initialization | |
*/ | |
var initialize = function() { | |
var latlng = new google.maps.LatLng(59.918118, 10.736732); | |
var myOptions = { | |
zoom: 12, | |
center: latlng, | |
mapTypeId: google.maps.MapTypeId.ROADMAP | |
}; | |
map = new google.maps.Map(document.getElementById("map_canvas"), myOptions); | |
addSheep(15); | |
} | |
return function() { | |
$(document).ready(function($) { | |
initialize(); | |
}); | |
}; | |
}(jQuery))(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment