ss
This commit is contained in:
commit
5a51cd21a8
|
@ -5,41 +5,31 @@ $(function() {
|
||||||
// map.addLayer(baseLayer);
|
// map.addLayer(baseLayer);
|
||||||
var geojson_format = new OpenLayers.Format.GeoJSON();
|
var geojson_format = new OpenLayers.Format.GeoJSON();
|
||||||
var jsonLayer = new OpenLayers.Layer.Vector();
|
var jsonLayer = new OpenLayers.Layer.Vector();
|
||||||
|
|
||||||
map.addLayers([baseLayer, jsonLayer]);
|
map.addLayers([baseLayer, jsonLayer]);
|
||||||
var center = new OpenLayers.LonLat(-95, 37.5).transform(
|
var center = new OpenLayers.LonLat(-95, 37.5).transform(
|
||||||
new OpenLayers.Projection("EPSG:4326"),
|
new OpenLayers.Projection("EPSG:4326"),
|
||||||
map.getProjectionObject()
|
map.getProjectionObject()
|
||||||
);
|
);
|
||||||
map.setCenter(center, 4);
|
map.setCenter(center, 4);
|
||||||
|
var mapControl = new OpenLayers.Control.SelectFeature(jsonLayer, {hover: true});
|
||||||
|
map.addControl(mapControl);
|
||||||
$('.first').click(function() {
|
mapControl.activate();
|
||||||
$('#page_no').val('1');
|
jsonLayer.events.on({
|
||||||
$('#searchForm').submit();
|
'featureselected': onFeatureSelect,
|
||||||
|
'featureunselected': onFeatureUnselect
|
||||||
});
|
});
|
||||||
|
|
||||||
$('.last').click(function() {
|
|
||||||
var lastPage = parseInt($('#totalPages').text());
|
|
||||||
$('#page_no').val(lastPage);
|
|
||||||
$('#searchForm').submit();
|
|
||||||
});
|
|
||||||
|
|
||||||
$('.next').click(function() {
|
function getFeatureById(id) {
|
||||||
var currPage = parseInt($('#page_no').val());
|
var features = jsonLayer.features;
|
||||||
var lastPage = parseInt($('#totalPages').text());
|
for (var i=0; i < features.length; i++) {
|
||||||
if (currPage < lastPage) {
|
if (features[i].attributes.id == id) {
|
||||||
$('#page_no').val(currPage + 1);
|
return features[i];
|
||||||
$('#searchForm').submit();
|
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
|
||||||
$('.previous').click(function() {
|
|
||||||
var currPage = parseInt($('#page_no').val());
|
|
||||||
if (currPage > 1) {
|
|
||||||
$('#page_no').val(currPage - 1);
|
|
||||||
$('#searchForm').submit();
|
|
||||||
}
|
}
|
||||||
});
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
$('#searchForm').submit(function(e) {
|
$('#searchForm').submit(function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
@ -83,10 +73,47 @@ $(function() {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/* pagination code */
|
||||||
|
$('.first').click(function() {
|
||||||
|
$('#page_no').val('1');
|
||||||
|
$('#searchForm').submit();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$('.last').click(function() {
|
||||||
|
var lastPage = parseInt($('#totalPages').text());
|
||||||
|
$('#page_no').val(lastPage);
|
||||||
|
$('#searchForm').submit();
|
||||||
|
});
|
||||||
|
|
||||||
|
$('.next').click(function() {
|
||||||
|
var currPage = parseInt($('#page_no').val());
|
||||||
|
var lastPage = parseInt($('#totalPages').text());
|
||||||
|
if (currPage < lastPage) {
|
||||||
|
$('#page_no').val(currPage + 1);
|
||||||
|
$('#searchForm').submit();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
$('.previous').click(function() {
|
||||||
|
var currPage = parseInt($('#page_no').val());
|
||||||
|
if (currPage > 1) {
|
||||||
|
$('#page_no').val(currPage - 1);
|
||||||
|
$('#searchForm').submit();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
/* pagination code end */
|
||||||
|
|
||||||
function getRow(props) {
|
function getRow(props) {
|
||||||
var $tr = $('<tr />');
|
var $tr = $('<tr />').attr("id", "feature" + props.id).data("id", props.id).hover(function() {
|
||||||
|
var id = $(this).data("id");
|
||||||
|
var feature = getFeatureById(id);
|
||||||
|
mapControl.select(feature);
|
||||||
|
}, function() {
|
||||||
|
var id = $(this).data("id");
|
||||||
|
var feature = getFeatureById(id);
|
||||||
|
mapControl.unselect(feature);
|
||||||
|
});
|
||||||
var $one = $('<td />').appendTo($tr);
|
var $one = $('<td />').appendTo($tr);
|
||||||
var $a = $('<a />').attr("href", "/admin/places/feature/" + props.id).text(props.preferred_name).appendTo($one);
|
var $a = $('<a />').attr("href", "/admin/places/feature/" + props.id).text(props.preferred_name).appendTo($one);
|
||||||
// var $a2 = $('<a />').addClass("viewSimilar").attr("target", "_blank").attr("href", "/search_related?id=" + props.id).text("view similar").appendTo($one);
|
// var $a2 = $('<a />').addClass("viewSimilar").attr("target", "_blank").attr("href", "/search_related?id=" + props.id).text("view similar").appendTo($one);
|
||||||
|
@ -97,6 +124,27 @@ function getRow(props) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
function onFeatureSelect(f) {
|
||||||
|
var id = f.feature.attributes.id;
|
||||||
|
// $('.highlightOverlay').hide().remove();
|
||||||
|
// $('img').removeClass('mapSelect');
|
||||||
|
var $tr = $('#feature' + id);
|
||||||
|
$tr.css({"font-weight": "bold"});
|
||||||
|
}
|
||||||
|
|
||||||
|
function onFeatureUnselect(f) {
|
||||||
|
var id = f.feature.attributes.id;
|
||||||
|
// $('.highlightOverlay').hide().remove();
|
||||||
|
// $('img').removeClass('mapSelect');
|
||||||
|
var $tr = $('#feature' + id);
|
||||||
|
$tr.css({"font-weight": "normal"});
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
function getLi(props) {
|
function getLi(props) {
|
||||||
var $li = $('<li />').addClass("mapListItem").attr("data-id", props.id);
|
var $li = $('<li />').addClass("mapListItem").attr("data-id", props.id);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user