Popup Openlayers
Geschrieben von QJanaQ (Gast) am 08. Mai 2014 13:25:42: [flux]
Hallo zusammen,
ich habe Probleme mit den Popup bei Openlayers 3.
Wenn ich auf eine Position am Bild klicke und dann das Bild verschiebe, dann verschiebt sich das Pop-Up-Fenster nicht mit. Und ich weiß nicht wo der Fehler gerade liegt. Ich habe von Openlayers 3 popup.html und popup.js so ähnlich gemacht. Ich poste mal meinen Code hier rein:
Html:
... <div␣id="map"␣class="map"> <div␣id="popup"␣class="ol-popup"></div> </div> ...
Javascript:
var␣popup␣=␣new␣ol.Overlay({ element:␣document.getElementById('popup') });
var␣iconFeature␣=␣new␣ol.Feature({ geometry:␣new␣ol.geom.Point([22,␣5])␣//is␣only␣an␣example });
var␣iconStyle␣=␣new␣ol.style.Style({ image:␣new␣ol.style.Icon({ src:␣'img/icon.png' }) });
iconFeature.setStyle(iconStyle);
var␣vectorSource␣=␣new␣ol.source.Vector({ features:␣[iconFeature] });
var␣vectorLayer␣=␣new␣ol.layer.Vector({ source:␣vectorSource }); var␣map␣=␣new␣ol.Map({ layers:␣[ new␣ol.layer.Image({ source:␣new␣ol.source.ImageStatic({ url:␣'img/picture.png', imageSize:␣[566,␣145], projection:␣pixelProjection, imageExtent:␣pixelProjection.getExtent() }) }), vectorLayer], overlays:␣[popup], target:␣'map', view:␣new␣ol.View2D({ projection:␣ownProjection, center:␣ol.extent.getCenter(ownProjection.getExtent()), zoom:␣2 }) });
map.on('singleclick',␣function(evt){ var␣element␣=␣popup.getElement(); var␣coord␣=␣evt.coordinate; var␣hdms␣=␣ol.coordinate.toStringHDMS(ol.proj.transform( coord␣,␣'EPSG:3857',␣'EPSG:4326'));
$(element).popover('destroy'); popup.setPosition(coord␣);
$(element).popover({ 'placement':␣'top', 'animation':␣false, 'html':␣true, 'content':␣'<p>Coords:␣</p><code>x:'␣+␣␣coord␣[0]␣+␣'␣m␣</br>␣y:'␣+␣coord␣[1]␣+␣'␣m</code>' }); $(element).popover('show');
});
Ich hoffe, dass ihr bei meinem Problem weiter helfen könnt. Denn popup von Openlayers 3 funktioniert einwandfrei, aber mit ImageStatic irgendwie nicht.
lg
QJanaQ
Antworten:
- Re: Popup Openlayers · QJanaQ (Gast) · 09.05.2014 08:45 [flux]
- Re: Popup Openlayers · viw (Gast) · 09.05.2014 10:18 [flux]
- Re: Popup Openlayers · wambacher (Gast) · 09.05.2014 11:00 [flux]
- Re: Popup Openlayers · QJanaQ (Gast) · 14.05.2014 13:12 [flux]
- Re: Popup Openlayers · maxbe (Gast) · 14.05.2014 13:40 [flux]
- Re: Popup Openlayers · QJanaQ (Gast) · 04.06.2014 09:58 [flux]
- Re: Popup Openlayers · frabron (Gast) · 04.06.2014 12:26 [flux]