Commit 8439e4d2 authored by jonnybradley's avatar jonnybradley

[MRG] Automatic merge, branches/20.x 70440 to 70445

parents 48d2bf15 a6151894
Pipeline #72080831 failed with stages
in 25 minutes and 51 seconds
......@@ -260,15 +260,17 @@
}
},
createMarkerStyle = function (feature) {
return new ol.style.Style({
geometry: feature.getGeometry(),
image: new ol.style.Icon({
anchor: [feature.get("offsetx"), feature.get("offsety")],
anchorXUnits: "pixels",
anchorYUnits: "pixels",
src: feature.get("url")
})
});
if (feature.get("intent") === "marker") {
return new ol.style.Style({
geometry: feature.getGeometry(),
image: new ol.style.Icon({
anchor: [feature.get("offsetx"), feature.get("offsety")],
anchorXUnits: "pixels",
anchorYUnits: "pixels",
src: feature.get("url")
})
});
}
}, invisibleFill = new ol.style.Fill({
color: 'rgba(255, 255, 255, 0.01)'
}),
......@@ -358,6 +360,19 @@
})]);
}
if ($(container).data("popup-style")) {
var selectionInteraction = new ol.interaction.Select({
style: createMarkerStyle,
layers: [vectors]
});
container.map.addInteraction(selectionInteraction);
// use select to make popup
selectionInteraction.on('select', container.showPopup);
}
} else {
vectors = container.layers[name] = new ol.layer.Vector({
......@@ -789,7 +804,7 @@
// based on https://gis.stackexchange.com/a/166745/25953
var displayFeatureInfo = function (pixel, evt) {
container.displayFeatureInfo = function (pixel, evt) {
$mapBootstrapDummy.tooltip("hide");
var feature, layer, both = map.forEachFeatureAtPixel(pixel, function (feature, layer) {
return [feature, layer];
......@@ -834,7 +849,8 @@
animation: false,
trigger: "manual",
html: true,
title: feature.get("content")
title: feature.get("content"),
container: "body"
})
.tooltip("show");
}
......@@ -845,20 +861,14 @@
$mapBootstrapDummy.tooltip('hide');
return true;
}
displayFeatureInfo(map.getEventPixel(evt.originalEvent), evt);
container.displayFeatureInfo(map.getEventPixel(evt.originalEvent), evt);
return true;
});
}
// use select to make popup
if ($(container).data("popup-style")) {
var selectionInteraction = new ol.interaction.Select({
});
map.addInteraction(selectionInteraction);
selectionInteraction.on('select', function (e) {
container.showPopup = function (e) {
var pixel, feature, features = e.target.getFeatures();
if (features.getLength()) {
......@@ -868,6 +878,17 @@
feature = clusterFeatures[0];
} else {
selectionInteraction.getFeatures().clear();
var extent = ol.extent.createEmpty();
for (var i = 0; i < clusterFeatures.length; ++i) {
ol.extent.extend(extent, clusterFeatures[i].getGeometry().getExtent());
}
container.map.getView().fit(
extent,
{
duration: 2000,
padding: [10,5,10,5]
}
);
return;
}
} else {
......@@ -897,7 +918,8 @@
event: event,
element: this,
callback: function (event, $html) {
var title = $html.find("h1").remove().text() || feature.get("content"),
var title = $html.find("h1").remove().text() || feature.get(
"content"),
$header = $(".modal-header", $modal);
$html.find("a.service-dialog").clickModal({});
......@@ -915,7 +937,8 @@
$(".modal-content", $modal).append(
$("<div class='modal-body'>").append($html),
$("<div class='modal-footer'>").append(
$('<button type="button" class="btn btn-secondary" data-dismiss="modal">' + tr('Close') + '</button>')
$('<button type="button" class="btn btn-secondary" data-dismiss="modal">'
+ tr('Close') + '</button>')
)
);
}
......@@ -960,7 +983,14 @@
});
break;
}
});
};
var selectionInteraction = new ol.interaction.Select({});
map.addInteraction(selectionInteraction);
// use select to make popup
selectionInteraction.on('select', container.showPopup);
}
......@@ -1050,18 +1080,14 @@
container.markerIcons.loadMarker('selection', 'lib/openlayers/img/marker-gold.svg');
if (navigator.geolocation && navigator.geolocation.getCurrentPosition) {
container.toMyLocation = $('<a/>')
.css('display', 'block')
container.toMyLocation = $('<a class="btn btn-sm btn-info">')
.attr('href', '')
.click(function () {
navigator.geolocation.getCurrentPosition(function (position) {
var lonlat = new ol.LonLat(position.coords.longitude, position.coords.latitude).transform(
new ol.proj.Projection("EPSG:4326"),
map.getProjectionObject()
);
map.setCenter(lonlat);
map.zoomToScale(position.coords.accuracy * ol.INCHES_PER_UNIT.m);
var view = map.getView();
view.setCenter(ol.proj.fromLonLat([position.coords.longitude, position.coords.latitude]));
view.setZoom(view.getZoomForResolution(position.coords.accuracy));
$(container).addMapMarker({
lat: position.coords.latitude,
......@@ -1078,8 +1104,7 @@
}
}
container.searchLocation = $('<a/>')
.css('display', 'block')
container.searchLocation = $('<a class="btn btn-sm btn-info">')
.attr('href', '')
.click(function () {
var address = prompt(tr('What address are you looking for?'), "");
......@@ -1775,14 +1800,15 @@
markerLayerSource = markerLayerSource.getSource(); // Cluster layer source
}
markerLayerSource.addFeatures([feature]);
if (options.unique) {
if (container.uniqueMarkers[options.unique]) {
markerLayer.removeFeatures([container.uniqueMarkers[options.unique]]);
markerLayerSource.removeFeature(container.uniqueMarkers[options.unique]);
delete container.uniqueMarkers[options.unique];
}
}
markerLayerSource.addFeatures([feature]);
if (options.unique) {
container.uniqueMarkers[options.unique] = feature;
$(container).trigger(options.unique + 'Change', options);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment