Fix automatic size detection for map popups.
This commit is contained in:
parent
d274c0e3d8
commit
28e9a84da2
3 changed files with 27 additions and 31 deletions
|
@ -14,10 +14,7 @@
|
|||
|
||||
<tr><td></td><td>
|
||||
<p>Update home location when I click on the map? <input type="checkbox" value="1" <% unless @user.home_lat and @user.home_lon %> checked="checked" <% end %> id="updatehome" /> </p>
|
||||
<div id="map" style="border: 1px solid black; position: relative; width : 90%; height : 300px;">
|
||||
<% # This now just used to detect the width/height required for the popup. %>
|
||||
<p id="highlightinfo"></p>
|
||||
</div>
|
||||
<div id="map" style="border: 1px solid black; position: relative; width : 90%; height : 300px;"></div>
|
||||
</td></tr>
|
||||
</table>
|
||||
<%= submit_tag 'Save Changes' %>
|
||||
|
|
|
@ -73,17 +73,11 @@ function addMarkerToMap(position, icon, description) {
|
|||
}
|
||||
|
||||
function openMapPopup(marker, description) {
|
||||
// var box = document.createElement("div");
|
||||
// box.innerHTML = description;
|
||||
// box.style.display = 'none';
|
||||
// box.style.width = "200px";
|
||||
// document.body.appendChild(box);
|
||||
|
||||
closeMapPopup();
|
||||
|
||||
popup = new OpenLayers.Popup.AnchoredBubble("popup", marker.lonlat,
|
||||
new OpenLayers.Size(200, 50),
|
||||
"<p>" + description + "</p>",
|
||||
sizeMapPopup(description),
|
||||
"<p style='padding-right: 28px'>" + description + "</p>",
|
||||
marker.icon, true);
|
||||
popup.setBackgroundColor("#E3FFC5");
|
||||
map.addPopup(popup);
|
||||
|
@ -98,6 +92,27 @@ function closeMapPopup() {
|
|||
}
|
||||
}
|
||||
|
||||
function sizeMapPopup(text) {
|
||||
var box = document.createElement("div");
|
||||
|
||||
box.innerHTML = text;
|
||||
box.style.visibility = "hidden";
|
||||
box.style.position = "absolute";
|
||||
box.style.top = "0px";
|
||||
box.style.left = "0px";
|
||||
box.style.width = "200px";
|
||||
box.style.height = "auto";
|
||||
|
||||
document.body.appendChild(box);
|
||||
|
||||
var width = box.offsetWidth;
|
||||
var height = box.offsetHeight;
|
||||
|
||||
document.body.removeChild(box);
|
||||
|
||||
return new OpenLayers.Size(width + 30, height + 24);
|
||||
}
|
||||
|
||||
function removeMarkerFromMap(marker){
|
||||
markers.removeMarker(marker);
|
||||
}
|
||||
|
|
|
@ -529,26 +529,10 @@ input {
|
|||
white-space: nowrap;
|
||||
}
|
||||
|
||||
/**
|
||||
* This now just used to detect the width/height required for the popup.
|
||||
*/
|
||||
#map p#highlightinfo {
|
||||
visibility : hidden;
|
||||
position : absolute;
|
||||
z-index : 10000;
|
||||
background : white;
|
||||
border : 1px solid black;
|
||||
left : 50px;
|
||||
top : 5px;
|
||||
margin : 0px;
|
||||
padding : 2px;
|
||||
}
|
||||
|
||||
#map p#highlightinfo p, #popup p {
|
||||
#map #popup p {
|
||||
margin : 0;
|
||||
padding : 2px;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**State of the Map */
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue