I have done point layer overlay with openlayer. Whenever i click any point, its showing me all the data of the table in popup. How to control amount of data in the popup?
Code is:
....
info = new OpenLayers.Control.WMSGetFeatureInfo({
url: 'http://localhost:8080/geoserver/layername/wms', // geoserver point layer
title: 'Identify features by clicking',
queryVisible: true,
eventListeners: {
getfeatureinfo: function(event) {
map.addPopup(new OpenLayers.Popup.FramedCloud(
"ABCD",
map.getLonLatFromPixel(event.xy),
null,
event.text,
null,
true
));
}
}
});
map.addControl(info);
info.activate();
Screenshot of current popup is
()
I just want location_name and some html content in popup. How to do that?
Related
In most of my grids, if I want to perform a "custom operation" that displays some data in a jqGrid modal form and allow the users to click "submit" to do something, I am able to simply leverage the existing "Edit" operation and tweak it to my needs.
However, I am working on a grid where the Add, Edit, and Delete operations are all in use, and I need an additional "custom operation" that opens a jqGrid modal form to display a couple of the columns along with a submit button to send the key ID to the target URL.
Normally this is very easy to simply re-task the Edit function, but since Edit is in use, I'm not sure how to do this. Does jqGrid have a proper method for creating new custom operations that display modal forms just like Edit does?
In the end, I was not able to find a way to do this through "core" jqGrid features and ended up simply adding a new button to the grid which opens my own custom modal box.
The multi-select features of jqGrid were also used to allow the user to select multiple records to be passed off to this custom function when the new button is clicked.
Here was the code for adding the button to jqGrid. The AJAX call retrieves the HTML content for the modal that is being populated (in JSON format):
.navButtonAdd('#listAllSupplierPurchasesGridPager', {
caption: "Mark Paid",
buttonicon: "ui-icon-add",
onClickButton: function () {
var s;
s = $("#listAllSupplierPurchasesGrid").jqGrid('getGridParam', 'selarrrow');
if (s.length > 0) {
// Make AJAX call to get the dynamic form content
$.ajax({
cache: false,
async: true,
type: 'POST',
url: "/TargetItems/MarkPurchasesPaidRequest",
data: {
PurchaseIds: JSON.stringify(s)
},
success: function (content) {
// Add the content to the div
$('#MarkPurchasePaidModal').html(content);
// Display the modal
$("#MarkPurchasePaidModal").dialog("open");
},
error: function (res, status, exception) {
alert(status + ": " + exception);
},
modal: true
});
}
},
position: "first"
})
The jQuery for setting up the basic modal box:
$("#MarkPurchasePaidModal").dialog({
autoOpen: false,
width: 768,
autoheight: true,
show: {
effect: "blind",
duration: 250
},
modal: true
});
And the div HTML to hold the modal:
<div id="MarkPurchasePaidModal" role="dialog" title="Mark Purchases Paid" class="container"></div>
I am building an online map app, using Openlayers, which enables popup information by clicking on features. The info was brought by wms getfeatureinfo.
I wonder if there is a simple way to change the mouse cursor to, say, hand when the mouse hovers over the selectable feature. This is to help users identify that the features are clickable and info can be retrieved.
The attached is my current code. Thanks!
shelter_info = new OpenLayers.Control.WMSGetFeatureInfo ({
url:"****",
title: 'Identify evacuation centres by clicking',
layers:[evacuation_center],
queryVisible: true,
hover: true,
eventListeners:{
getfeatureinfo: function(event){
if (event.text.indexOf("<b>") != -1){ //only display popup when selected the WMS object.
var popup = new OpenLayers.Popup.FramedCloud(
"shelter_popup",
map.getLonLatFromPixel(event.xy),
null,
event.text,
null,
true,
null
);
popup.autoSize = true;
popup.minSize = new OpenLayers.Size(180,180);
//feature.popup = popup;
map.addPopup(popup);
}
}
}
});
I am using the WMSGetFeatureInfo control to retrieve feature attributes from geoserver and display in popups.
I've setup the proxyhost at localhost and the popup is working fine now. I am using eventListeners.
After it executes the last line, map.addPopup(popup), the layout of the html file changes as shown in the attached images.
The codes is as below:
shelter_info = new OpenLayers.Control.WMSGetFeatureInfo ({
url:"http://130.95.44.145:8080/geoserver/Bushfire_Com_Study/wms",
title: 'Identify features by clicking',
layers:[evacuation_center],
queryVisible: true,
hover: true,
eventListeners:{
getfeatureinfo: function(event){
//only display popup when selected the WMS object
if (event.text.indexOf("<table class=\"featureInfo\">") != -1) {
var popup = new OpenLayers.Popup.FramedCloud(
"shelter_popup",
map.getLonLatFromPixel(event.xy),
null,
event.text,
null,
true,
null
);
popup.autoSize = true;
popup.minSize = new OpenLayers.Size(180,180);
map.addPopup(popup);
}
}
}
});
Before adding popups:
After adding popups:
I have a Dojo FilteringSelect that takes about 20 seconds to load its values from the dB when the user clicks the arrow in the list box. I'd like to display a progress spinner while waiting for the data to be returned from the dB. Any ideas what event I would use to show my spinner when the data is being retrieved from the db and what event to hide the spinner when it completes? Thanks...
new FilteringSelect({
store: new dojo.data.ItemFileReadStore({ url: "some url here" }),
autocomplete: true,
maxHeight: "300",
required: false,
id: "country_select_id",
onChange: function(data) {
dojo.byId("case_info_status").innerHTML = " ";
}
}, "country_select_id");
I bet you could go a long way in the select._fetchHandle deferred and the store._fetchItems. Try this
var select = new .... Your FilteringSelect Construct( {} );
select._fetchHandle.addCallback(function() {
// success callback
dojo.style(dojo.byId('spinner'), "display", "none");
});
dojo.connect(select.store._fetchItems, function() {
if(select.store._loadFinished) return; // no-op
dojo.style(dojo.byId('spinner'), "display", "block");
});
EDIT:
select._fetchHandle will only be present briefly during the actual download (suppose we can hook onto it after select onOpen called). Instead, another private method in ItemFileReadStore comes in handy
dojo.connect(select.store._getItemsFromLoadedData, function() {
dojo.style(dojo.byId('spinner'), "display", "none");
});
Let's say I have a grid with multiselect option on, when user selects 4 lists and wants to get the values ( alerted on screen) how would I do that? And how would I disable buttons untill at least one list is selected?
All questions you've asked are answered many times already. Also there are good ExtJS examples on sencha.com. For example list view grid shows multiple select and editable grid with writable store shows button enable on click. But THE MOST important is documentation! Let me explain functionality on following code. Most of it is from list view example.
This grid gets JSON from list.php which has following structure
{"authors":[{"surname":"Autho1"},{"surname":"Autho2"}]}
And the grid:
Ext.require([
'Ext.grid.*',
'Ext.data.*',
'Ext.panel.*'
]);
Ext.onReady(function(){
// Here i've definned simple model with just one field
Ext.define('ImageModel', {
extend: 'Ext.data.Model',
fields: ['surname']
});
var store = Ext.create('Ext.data.JsonStore', {
model: 'ImageModel',
proxy: {
type: 'ajax',
url: 'list.php',
reader: {
type: 'json',
root: 'authors'
}
}
});
store.load();
var listView = Ext.create('Ext.grid.Panel', {
id: 'myPanel', // Notice unique ID of panel
width:425,
height:250,
collapsible:true,
renderTo: Ext.getBody(),
store: store,
multiSelect: true,
viewConfig: {
emptyText: 'No authors to display'
},
columns: [{
text: 'File',
flex: 50,
// dataIndex means which field from model to load in column
dataIndex: 'surname'
}],
dockedItems: [{
xtype: 'toolbar',
items: [{
// This button will log to console authors surname who are selected
// (show via firebug or in chrome js console for example)
text: 'Show selected',
handler: function() {
// Notice that i'm using getCmp(unique Id of my panel)
// to get panel regerence. I could also use
// this.up('toolbar').up('myPanel')
// see documentation for up() meaning
var selection = Ext.getCmp('myPanel').getSelectionModel().getSelection();
for (var i=0; i < selection.length; i++) {
console.log(selection[i].data.surname);
}
}
},{
text: 'Disabled btn',
id: 'myHiddenBtn', // Notice unique ID of my button
disabled: true // disabled by default
}]
}]
});
// Here i'm waiting for event which is fired
// by grid panel automatically when you click on
// any item of grid panel. Then I lookup
// my button via unique ID and set 'disabled' property to false
listView.on('itemclick', function(view, nodes){
Ext.getCmp('myHiddenBtn').setDisabled(false);
});
});
I didn't knew how to do this from top of my head, but I used documentation and the result works ;-). See Grid panel docs for more information.