+ function makeMarkerFunction( i ) {
+ return function() { markerOnClick( i ); };
+ }
+
+ function markerOnClick( i ) {
+ var html, position;
+ if( typeof( i ) == 'number' ) {
+ html = '<p>Nearby mapper: <a href="/user/'+nearest[i].display_name+'">'+nearest[i].display_name+'</a></p>';
+ html += '<p style="text-align:right">(<a href="#" onclick="return closePopup();">close</a>)</p>';
+ position = lonlat2mercator( new OpenLayers.LonLat( nearest[i].home_lon, nearest[i].home_lat ) );
+ } else {
+ html = '<p>Your location (<a href="#" onclick="return closePopup()">close</a>)</p>';
+ position = new OpenLayers.LonLat(mlon,mlat);
+ }
+ var box = document.getElementById( 'highlightinfo' );
+ box.innerHTML = html;
+ closePopup();
+ popup = new OpenLayers.Popup.AnchoredBubble( 'popup', position, new OpenLayers.Size( box.offsetWidth, box.offsetHeight ), html, OpenLayers.Marker.defaultIcon(), true );
+ map.addPopup( popup );
+ }
+
+ function closePopup() {
+ if( popup ) {
+ map.removePopup( popup );
+ delete popup;
+ }
+ return false;
+ }
+