[OpenLayers-Users] Help dealing with popup clicks verse
clickhandlers
Eric Lemoine
eric.c2c at gmail.com
Tue May 27 01:46:33 EDT 2008
On Tue, May 27, 2008 at 7:42 AM, 小粟 <weimin_su at 126.com> wrote:
> Hope this is useful!
You don't use a click handler (OpenLayers.Handler.Click) so your
example doesn't really pertain to Stephen's case. Thanks,
--
Eric
> var feature, popup;
> var contentHTML;
> var marker, markers;
>
> function addMarker(lon, lat, cHtml)
> {
> if(markers == null)
> {
> markers = new OpenLayers.Layer.Markers("热点层");
> map.addLayer(markers);
> }
>
> if(feature != null)
> {
> feature.destroy();
> if(popup != null)
> {
> popup.destroy();
> popup = null;
> }
> }
> feature = new OpenLayers.Feature(layer, new OpenLayers.LonLat(lon, lat));
> //feature.closeBox = false;
> feature.popupClass = OpenLayers.Popup.FramedBubbleM2Ex;
> //feature.popupClass = OpenLayers.Popup.FramedCloud;
> var markerIcon = new OpenLayers.Icon("mainimg/marker.gif", new OpenLayers.Size(37.5,37.5));
> if(marker == null)
> {
> marker = feature.createMarker();
> //marker.icon = markerIcon;
> }
> else
> {
> markers.removeMarker(marker);
> marker = feature.createMarker();
> //marker.icon = markerIcon;
> }
>
> markers.addMarker(marker);
> contentHTML = cHtml;
> marker.events.register("mousedown", marker, mousedown);
> }
>
> function mousedown(evt) {
> if (popup == null) {
> popup = feature.createPopup(true);
> popup.setContentHTML(contentHTML);
> markers.map.addPopup(popup);
> } else {
> popup.toggle();
> }
>
> OpenLayers.Event.stop(evt);
> }
More information about the Users
mailing list