update examples
git-svn-id: http://svn.openlayers.org/trunk/openlayers@463 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
+43
-11
@@ -12,7 +12,8 @@
|
||||
<script type="text/javascript">
|
||||
<!--
|
||||
var map, layer, popup;
|
||||
|
||||
var markers, feature;
|
||||
|
||||
function init(){
|
||||
map = new OpenLayers.Map('map');
|
||||
layer = new OpenLayers.Layer.WMS( "OpenLayers WMS",
|
||||
@@ -52,16 +53,48 @@
|
||||
map.addPopup(popup);
|
||||
}
|
||||
|
||||
function addAnchorBubble() {
|
||||
popup = new OpenLayers.Popup.AnchoredBubble("chicken",
|
||||
new OpenLayers.LonLat(5,40),
|
||||
new OpenLayers.Size(200,200),
|
||||
"example popup");
|
||||
function addMarker() {
|
||||
|
||||
markers = new OpenLayers.Layer.Markers("zibo");
|
||||
map.addLayer(markers);
|
||||
|
||||
feature = new OpenLayers.Feature(layer,
|
||||
new OpenLayers.LonLat(0,0));
|
||||
|
||||
|
||||
var marker = feature.createMarker();
|
||||
|
||||
markers.addMarker(marker);
|
||||
marker.events.register("mousedown", marker, mousedown);
|
||||
|
||||
}
|
||||
|
||||
popup.setBackgroundColor("yellow");
|
||||
popup.setOpacity(0.7);
|
||||
map.addPopup(popup);
|
||||
function mousedown() {
|
||||
if (popup == null) {
|
||||
popup = feature.createPopup();
|
||||
popup.setBackgroundColor("yellow");
|
||||
popup.setOpacity(0.7);
|
||||
popup.events.register("mousedown", popup, onPopupMouseDown);
|
||||
markers.map.addPopup(popup);
|
||||
} else {
|
||||
markers.map.removePopup(popup);
|
||||
popup.destroy();
|
||||
popup = null;
|
||||
}
|
||||
Event.stop(evt);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Event} evt
|
||||
*/
|
||||
function onPopupMouseDown(evt) {
|
||||
markers.map.removePopup(popup);
|
||||
popup.destroy();
|
||||
popup = null;
|
||||
Event.stop(evt);
|
||||
}
|
||||
|
||||
|
||||
function destroy() {
|
||||
popup.destroy();
|
||||
}
|
||||
@@ -77,8 +110,7 @@
|
||||
<body onload="init()">
|
||||
<div id="map"></div>
|
||||
<div style="background-color:purple" onclick="add()"> click to add Popup to map</div>
|
||||
<div style="background-color:green" onclick="addAnchor()"> click to add an Popup.Anchored</div>
|
||||
<div style="background-color:orange" onclick="addAnchorBubble()"> click to add Popup.AnchoredBubble</div>
|
||||
<div style="background-color:green" onclick="addMarker()"> click to add a Marker with an AnchoredBubble popup</div>
|
||||
<div style="background-color:blue" onclick="changer()"> click to modify popup's attributes</div>
|
||||
<div style="background-color:red" onclick="remove()"> click to remove the popup from map</div>
|
||||
</body>
|
||||
|
||||
Reference in New Issue
Block a user