No Load kml in Openlayers MVC ASP.NET - asp.net-mvc

I have a problem to load a kml map using OpenLayers.
I used this in this example:
http://www.openlayers.org/dev/examples/sundials.html
I put the following script to load the kml
var wms = new OpenLayers.Layer.WMS('OpenLayers WMS','http://vmap0.tiles.osgeo.org/wms/vmap0', { layers: 'basic' }, {});
var gphy = new OpenLayers.Layer.Google("Google", { type: G_PHYSICAL_MAP });
var geomor = new OpenLayers.Layer.Vector("KML", {
projection: map.displayProjection,
strategies: [new OpenLayers.Strategy.Fixed()],
protocol: new OpenLayers.Protocol.HTTP({
url: "/Shapes/Geomorfologia/est_temp2.kml",
format: new OpenLayers.Format.KML({
extractStyles: true,
extractAttributes: true
})
})
});
map.addLayers([wms, gphy, geomor]);
Only this KML is not loading from the folder where the KML is within the Visual Studio folder.
Can anyone tell me what's wrong.

Related

Use add files dialog in Electron testing with Spectron

I want to test my Electron application but I feel this is harder than I expected!
Just a simple thing as using the open file dialog seems impossible from what I've seen when I looked around a while!
Is it at all possible, or can I mock this behavior somehow?
My application adds the selected files to a file list and shows some result in a grid. If I can't open files I wont get the grid and can't test if it behaves as expected.
How should I approach this issue if I can't use the file dialog?
This is my test setup:
import { Application } from "spectron";
import { expect } from "chai";
describe("Application", function() {
this.timeout(10000);
let app: Application;
let browser: any;
before(async () => {
app = new Application({
path: electronPath,
args: [appPath],
});
await app.start();
browser = app.client;
await browser.waitUntilWindowLoaded();
});
after(() => {
await app.stop();
});
it("Starts application", async () => {
const count = await browser.getWindowCount();
expect(count).to.equal(1);
});
it("should add files", async function() {
await browser.click("#block-container > div.button-row > div:nth-child(1) > button:nth-child(1)");
// ???
});
});
And this is the addFiles method:
public addFiles() {
const selectedFiles: string[] = this.electronService.remote.dialog.showOpenDialogSync({
title: "Add files",
properties: ["openFile", "multiSelections"]
});
...
}

creating dynamic table with data from odata service in ui5

I'm a complete newb on sap ui5.
I'm trying to generating a table on my webpage generated in sap web ide.
The data for this table is a .json file accessed via odata service.
I've come this far:
oModel is generated:
function initModel() {
var sUrl = "/sap/opu/odata/sap/ZGWS_someService/CollectionSet?$format=json";
var oModel = new sap.ui.model.odata.ODataModel(sUrl, true);
sap.ui.getCore().setModel(oModel);
}
now I want to generate a table on my html site with the data in the .json file.
So I have to create columns based on the properties of the items and then filling the rows with the current data.
.json looks like this:
{
"d": {
"results": [
{
"property1": "123",
"property2": "346"
},
{
"property1": "123",
"property2": "555"
}
I have no solution for this yet - can you help me out?
greetz,
simon
I created the table in the controller and sorted the data via lodash.
Is that good practice?
var oTable = this.byId("table");
oTable.addColumn(new sap.ui.table.Column({
label: new sap.ui.commons.Label({
text: "Info1"
}),
sortProperty: "INTST",
template: new sap.ui.commons.TextView().bindProperty("text", "key")
}));
oTable.addColumn(new sap.ui.table.Column({
label: new sap.ui.commons.Label({
text: "Count"
}),
template: new sap.ui.commons.TextView().bindProperty("text", "value")
}));
$
.ajax({
url: '/.../ServiceSet',
jsonpCallback: 'getJSON',
contentType: "application/json",
dataType: 'json',
success: function(data, textStatus, jqXHR) {
var oModel = new sap.ui.model.json.JSONModel();
oModel.setData(data);
sap.ui.getCore().setModel(oModel);
//Create a model and bind the table rows to this model
//Get the forecastday array table from txt_forecast object
var aData = oModel.getProperty("/d/results");
var aData2 = _.countBy(_.map(aData, function(d) {
return d.VALUE;
}));
var aData3 = Object.keys(aData2).sort().map(key => ({
key,
value: aData2[key]
}));
oModel.setData({
modelData: aData3
});
oTable.setModel(oModel);
}
});
oTable.bindAggregation("rows", {
path: "/modelData"
});

Feature grid not taking data from geoserver layer WMS using geoext 3

this is my grid.js file which is included in the grid.html. I don't know what is wrong with my code. I have seen examples and tried to perform same with my geoserver layer but no output. My code after variable store is not working. I want to load my file on the web and display its data in feature grid using geoext 3.0.0. Kindly help.
Ext.require([
'Ext.container.Container',
'Ext.panel.Panel',
'Ext.grid.GridPanel',
'GeoExt.component.Map',
'GeoExt.data.store.Features'
]);
Ext.onReady(function () {
var wmsLayer = new ol.layer.Image({
source: new ol.source.ImageWMS({
url: 'http://localhost:8080/geoserver/opengeo/wms',
params: {'LAYERS': 'opengeo:abc'},
serverType: 'geoserver'
})
});
var baseLayer = new ol.layer.Tile({
source: new ol.source.TileWMS({
url: 'http://ows.terrestris.de/osm-gray/service',
params: {'LAYERS': 'OSM-WMS', 'TILED': true}
})
});
var view = new ol.View({
center: ol.proj.fromLonLat([75, 36]),
zoom: 8
});
var map = new ol.Map({
layers: [ baseLayer, wmsLayer ],
target: 'map',
view: view
});
var store = Ext.create("GeoExt.data.store", {
url: 'http://localhost:8080/geoserver/wms',
params: {'LAYERS': 'opengeo:abc'},
autoLoad: true
});
grid1 = Ext.create('Ext.grid.Panel', {
title: 'Main Cities',
border: true,
region: 'east',
store: store,
columns: [
{text: 'CityName', dataIndex: 'Name'}
],
width: 300
});
var mapComponent = Ext.create('GeoExt.component.Map', {
map: olMap
});
var mapPanel = Ext.create('Ext.panel.Panel', {
region: 'center',
height: 400,
layout: 'fit',
items: [mapComponent]
});
var description = Ext.create('Ext.panel.Panel', {
contentEl: 'description',
region: 'south',
title: 'Description',
height: 180,
border: false,
bodyPadding: 5,
autoScroll: true
});
Ext.create('Ext.Viewport', {
layout: 'border',
items: [mapPanel, grid1, description]
});
});
In the first lines you require GeoExt.data.store.Features but try to instantiate the package GeoExt.data.store later. Try this:
var store = Ext.create("GeoExt.data.store.Features", {
url: 'http://localhost:8080/geoserver/wms',
params: {'LAYERS': 'opengeo:abc'},
autoLoad: true
});
Also, you try to hand over a variable olMap to the GeoExt map component. You named it map some lines above. Try:
var mapComponent = Ext.create('GeoExt.component.Map', {
map: map
});

OpenLayers 3 Remote JSON Data

I have a remote JSON file with a list of houses in inventory. I wan't to plot these on an OL map. The JSON is coming from an API and isn't in standard GeoJSON. I need to get the coordinates from a collection called inventory which is nested one level down from the root object. How can I do this OL 3. In OL2 I did this using the protocol.Script() and on read parsing out the nested items that I needed. So far I have:
var myLayer = new ol.layer.Vector({
title: "Inventory",
source: new ol.source.Vector({
format: new ol.format.GeoJSON({
projection : "EPSG:4326",
url: "http://some.closed.api/inventory/",
strategy: ol.loadingstrategy.bbox
})
})
});
Any pointers to the most efficient way to do this would be appreciated.
I ended up with this solution:
var olSource = new ol.source.Vector(),
layer = new ol.layer.Vector({
source: olSource
});
function successHandler( data ) {
var transform = ol.proj.getTransform(
"EPSG:4326",
map.getView().getProjection()
);
var rootObj = "inventory",
items = data[ rootObj ] ? data[ rootObj ] : data;
items.forEach( function( item ) {
var feature = new ol.Feature( item );
var coordinate = transform(
[ parseFloat( item.longitude ), parseFloat( item.latitude) ]
);
var geometry = new ol.geom.Point( coordinate );
feature.setGeometry( geometry );
olSource.addFeature( feature );
});
}
$.ajax({
url: "http://some.closed.api/inventory",
dataType: 'jsonp',
params: { q: "seattle" },
jsonpCallback: "callback",
success: successHandler
});

Values not Populating in COMBOBOX even though it is fired the values from MVC

I am Very new to EXTJS.
i am adding a new combo to my html page using EXTJS in xxx.js file and fetching the values from MVC controller with sample information.
while debugging the MVC application it is sending the sample information when i send URL: xxxx/getSite from EXTJS.
but it is not showing the values which are fetching from Controller. i am adding the below code which i am using.
Please let me know my mistake.
My Ext JS Code:
var siteidStore = new Ext.data.JsonStore({
reader: new Ext.data.JsonReader({
fields: ['SiteName','SiteId']
}),
root: 'Site',
proxy: new Ext.data.HttpProxy({
url: 'Site/getSite',
method: "POST",
type: 'ajax',
reader: 'json'
}),
autoLoad: true
});
var combo = Ext.create('Ext.form.field.ComboBox', {
queryMode: 'local',
store: siteidStore,
fieldLabel: 'Site ID',
name: 'siteid',
displayField: 'SiteName',
valueField: 'SiteId',
triggerAction: 'all',
typeAhead: false,
forceSelection: true,
emptyText: 'Select Site',
hiddenName: 'SiteId',
selectOnFocus: true
});
MY MVC Appln Code from Controller:
publicActionResult getSite()
{
List<Combo> siteid = newList<Combo>();
siteid.Add(newCombo(1, "IND"));
siteid.Add(newCombo(2, "USA"));
siteid.Add(newCombo(3, "UK"));
return Json(new
{
Site = siteid,
}, JsonRequestBehavior.AllowGet);
}
Output of my C# code or Json:
{"Site":[{"SiteName":"IND","SiteId":1},{"SiteName":"USA","SiteId":2},{"SiteName":"UK","SiteId":3}]}
may be you forgot
renderTo : Ext.getBody()
inside combobox...

Resources