Make vector-layer example work when hosted
This commit is contained in:
@@ -54,9 +54,8 @@ $.getJSON('data/countries.geojson', function(data) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
var highlight;
|
var highlight;
|
||||||
var displayFeatureInfo = function(pixel) {
|
var displayFeatureInfo = function(coordinate) {
|
||||||
var oldHighlight = highlight;
|
var oldHighlight = highlight;
|
||||||
var coordinate = map.getCoordinateFromPixel(pixel);
|
|
||||||
var features = vectorSource.getAllFeaturesAtCoordinate(coordinate);
|
var features = vectorSource.getAllFeaturesAtCoordinate(coordinate);
|
||||||
var info = document.getElementById('info');
|
var info = document.getElementById('info');
|
||||||
if (features.length > 0) {
|
if (features.length > 0) {
|
||||||
@@ -73,13 +72,13 @@ var displayFeatureInfo = function(pixel) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
$(map.getViewport()).on('mousemove', function(evt) {
|
$(map.getViewport()).on('mousemove', function(evt) {
|
||||||
var pixel = map.getEventPixel(evt.originalEvent);
|
var coordinate = map.getEventCoordinate(evt.originalEvent);
|
||||||
displayFeatureInfo(pixel);
|
displayFeatureInfo(coordinate);
|
||||||
});
|
});
|
||||||
|
|
||||||
map.on('singleclick', function(evt) {
|
map.on('singleclick', function(evt) {
|
||||||
var pixel = evt.getPixel();
|
var coordinate = evt.getCoordinate();
|
||||||
displayFeatureInfo(pixel);
|
displayFeatureInfo(coordinate);
|
||||||
});
|
});
|
||||||
|
|
||||||
var highlightStyle = new ol.style.Style({
|
var highlightStyle = new ol.style.Style({
|
||||||
|
|||||||
Reference in New Issue
Block a user