Query looks like query.where = Abbrev = 'BLOC' OR Abbrev = 'ZACH' OR Abbrev = 'MSC'
function getLocRes(results) {
console.log("getLocRes",results);
var geom;
//geom = results.features[0].geometry;
//console.log("geom",geom);
//console.log("extent0",extent);
var symbol = new esri.symbol.SimpleFillSymbol(esri.symbol.SimpleFillSymbol.STYLE_SOLID, new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID, new dojo.Color([80, 0, 0]), 2), new dojo.Color([80, 0, 0, 0.5]));
var res = results.features;
console.log("symbol",symbol);
console.log("res.length",res.length);
//map.graphics.clear();
for (var i = 0;i < res.length; i++) {
console.log("i=",i);
console.log("res[i].geometry=",res[i].geometry);
var reGeo = res[i].geometry;
var graphic = new Graphic(reGeo,symbol);
var graphic = reGeo;
console.log("graphic=",graphic);
graphic.setSymbol(symbol);
map.graphics.add(graphic);
console.log(map.graphics.length);
}
//var extent = geom.getExtent();
alert(map.graphics.graphics.length);
//map.setExtent(extent, true);
console.log("extent1",extent);
}
http://www.dexconor.com/map/img/esri3.png
the image is result in chrome console
so it seems like something wrong with var graphic = new Graphic(reGeo,symbol);
even 'for' doesn't work.
Can anyone give me some ideas?
It might be a namespace issue, does this work?
new esri.Graphic(reGeo,symbol);
also, make sure the "esri/graphic" module is loaded through require.js
Related
I want to randomly apply styles to my ArtLayers.
To do this, I tested the applyStyle function.
ArtLayers.applyStyle
It works!)
But to solve my task I need all styles.
I can't find it in the documentation (photoshop-javascript-ref-2020).
Can you suggest something?
To get all the styles use this Action Manager function:
var allStyles = get_styles()
alert(allStyles); // ALLL the styles!
//alert(allStyles[22]); // Sunspots (texture)
function get_styles()
{
var ref = new ActionReference();
ref.putEnumerated( charIDToTypeID("capp"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
var appDesc = executeActionGet(ref);
var List = appDesc.getList(stringIDToTypeID('presetManager'));
var list = List.getObjectValue(3).getList(charIDToTypeID('Nm '));
var styleNames=[];
for (var i = 0; i < list.count; i++)
{
var str = list.getString(i);
styleNames.push(str);
}
return styleNames;
}
I have a question and also in need for help with my code.
I'm trying to create a script that can update metadata on picture. user can upload multiple images and the script automatically update the metadata like latitude and longitude from a list.
As i am a newbie in java script i can not understand why when i pass all my coordinates inside reader.onload it only take the last one and assign it to all my pictures.
My idea is: I loop through the images and assign to each image one coordinate chronologically, then i convert the coordinate to exifByte. Till here is all working fine but when i try to attach the exifByte to each image inside reader.onload it takes the last coordinate and assign it to all my images.
I hope the code below is clear enough for you guys
Any explanation or help would be much appreciated
Thanks
<script>
function Initialize() {
var fileCatcher = document.getElementById('file-catcher');
var fileInput = document.getElementById('file-input');
var fileListDisplay = document.getElementById('file-list-display');
var fileList = [];
var renderFileList, dispimg;
var x = [];
var jpeg;
fileInput.addEventListener('change', function (evnt) {
var files = evnt.target.files;
fileList = [];
for (var i = 0; i < fileInput.files.length; i++) {
fileList.push(fileInput.files[i]);
var file = fileInput.files[i];
x = (i);
var gpsIfd = {};
var rutedata = '<?php echo "$str" ?>';
points = rutedata.split(";").reverse();
for (var j=0; j<(points.length-x); j++) {
var mData = points[j].split(',');}
console.log("current point:");
console.log(x)
var lat = (mData[0]);
var lng = (mData[1]);
gpsIfd[piexif.GPSIFD.GPSLatitudeRef] = lat < 0 ? 'S' : 'N';
gpsIfd[piexif.GPSIFD.GPSLatitude] = piexif.GPSHelper.degToDmsRational(lat);
gpsIfd[piexif.GPSIFD.GPSLongitudeRef] = lng < 0 ? 'W' : 'E';
gpsIfd[piexif.GPSIFD.GPSLongitude] = piexif.GPSHelper.degToDmsRational(lng);
var exifObj = { "GPS":gpsIfd};
var exifBytes = piexif.dump(exifObj);
var c = document.createDocumentFragment();
var reader = new FileReader();
reader.onload = (e) => { // this is the problem loop only the last point'
var jpeg = piexif.insert(exifBytes, e.target.result);
console.log(lat); // here is logging the last point only
var image = new Image();
image.src = jpeg;
image.width = 500;
var el = $("<div></div>").append(image);
$("#resized").prepend(el);
};
reader.readAsDataURL(fileInput.files[i]);
}
renderFileList();
});
}
</script>
Since reader is async in nature, you get the last lat-lang. You can use closure to keep data. Else create a function to pass data.
More: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Closures
(function (byte, lats) {
var reader = new FileReader();
reader.onload = (e) => {
var jpeg = piexif.insert(byte, e.target.result);
console.log(lats); // here is logging the last point only
var image = new Image();
image.src = jpeg;
image.width = 500;
var el = $("<div></div>").append(image);
$("#resized").prepend(el);
};
})(exifBytes, lat);
I am creating an application with an acrobat dynamic stamp pop up window and I would like it to reflect the stamp comment. My dynamic stamp has some JavaScript that will generate a pop-up window. The information on the pop-up window text field will become part of the stamp. I'm trying to add the contents of the pop-up window in two areas.
On the Dynamic stamp (done)
On the Stamp Comments (need help)
Below I added the JavaScript I currently have. If anyone here can help me find a solution, I'd really appreciate it.
var builder =
{
// These map to Text Fields in the Stamp
textBoxes :
[
{ field:"IsoNum", description:"Isometric Number:", default:function() { return Collab.user; } }
]
}
/*********** belongs to: AcroForm:Calculation:Calculate ***********/
// SEE GLOBAL JAVASCRIPT SECTION FOR CUSTOMIZATION
if (event.source.forReal)
{
var stampDialog = CreateDialog(builder);
app.execDialog(stampDialog);
for (var i = 0; i < builder.textBoxes.length; ++i)
{
var t = builder.textBoxes[i];
this.getField(t.field).value = stampDialog.textBoxResults[i];
}
}
function CreateDialog(dialogBuilder)
{
var sd = new Object();
sd.builder = dialogBuilder;
sd.textBoxResults = new Array();
var optionsElements = new Array();
for (var i = 0; i < dialogBuilder.textBoxes.length; ++i)
{
var view = new Object();
view.type = "view";
view.align_children = "align_row";
view.elements = new Array();
var t = dialogBuilder.textBoxes[i];
var s = new Object();
s.type = "static_text";
s.item_id = "sta" + i;
s.name = t.description;
s.width = 110;
var e = new Object();
e.type = "edit_text";
e.item_id = "edt" + i;
e.width = 150;
view.elements[0] = s;
view.elements[1] = e;
optionsElements[i] = view;
}
var optionsCluster =
{
type: "cluster",
name: "Options",
elements: optionsElements
};
sd.initialize = function(dialog)
{
var init = new Object();
for (var i = 0; i < this.builder.textBoxes.length; ++i)
{
var t = this.builder.textBoxes[i];
var id = "edt" + i;
init[id] = t.default();
}
dialog.load(init);
};
sd.commit = function(dialog)
{
var res = dialog.store();
for (var i = 0; i < this.builder.textBoxes.length; ++i)
{
var t = this.builder.textBoxes[i];
var id = "edt" + i;
this.textBoxResults[i] = res[id];
}
};
sd.description =
{
name: "Stamp Dialog",
elements:
[
{
type: "view",
align_children: "align_fill",
elements:
[
optionsCluster
]
},
{
type: "ok"
}
]
};
return sd;
}
I don't have any specific code but it seems you understand enough Acrobat JavaScript to understand my instructions.
The dialog code runs between the time you select and position the stamp and when the stamp actually gets created. For that reason, you can't set the contents of the note directly in your code because the stamp annotation doesn't actually exist until your commit function finishes. What you have to do instead is create a function that sets the contents of the note inside a timeOut and use a delay of about a half second.
I have a UK county shape file (Multipolygon) using EPSG:4326 in my geoserver. I'm using open layers 3 to load this shape file in my application as below :
source = new ol.source.XYZ({url: '/gmaps?zoom={z}&x={x}&y={y}&Layers=UKCounties', crossOrigin: "anonymous"});
countiesLayer = new ol.layer.Tile({source: source});
map.addLayer(countiesLayer);
This works well. I have a requirement to get users current location which is done as
var coordinate = geolocation.getPosition();
I'm able to retrieve the correct lat & long here. Ex : Lat = 53.797534899999995, Lng = -1.5449. now I need to check which of the counties (polygon) these points are in using open layers 3 & Javascript.
Using Geoserver WFS, I'm able to get the bounding box of each of the counties as
$.each(features, function(index, eachFeature) {
var bbox = eachFeature.properties.bbox;
if (bbox != null) {
var bottomLeft = ([bbox[0], bbox[1]]);
var topRight = ([bbox[2], bbox[3]]);
var extent = new ol.extent.boundingExtent([bottomLeft, topRight]);
if (ol.extent.containsXY(extent1,lat,long)) {
alert("got the feature");
}
}
});
The issue is my code doesn't print the alert statement.I've also tried using
if (ol.extent.containsXY(extent,long,lat))
and
var XY = ol.proj.transform([long, lat], 'EPSG:4326', 'EPSG:3857');
if (ol.extent.containsXY(extent,XY[0],XY[1]))
if (ol.extent.containsXY(extent,XY[1],XY[0]))
But none of these print the alert. Is there anything wrong in this?
Before answering your question, I did not know the method of "ol.extent.containsXY".
I used my poor logic! I detected a feature if in a polygon by follwing :
transform feature and container(polygon) to coordinate [lon, lat]
detect the container if contain the feature
extent array rule [minLon, minLat, maxLon, maxLat]
code snippet: (my destinationPro:'EPSG:3857', sourcePro:'EPSG:4326')
QyGIS.prototype.isInner = function(featureExtent, containerExtent) {
var featureLonLat = ol.proj.transformExtent(featureExtent, destinationPro, sourcePro);
var containerLonLat = ol.proj.transformExtent(containerExtent, destinationPro, sourcePro);
// in my condition, the feature is a point, so featureLonLat[0] = featureLonLat[2], featureLonLat[1] = featureLonLat[3]. what's more extent have four value in a array so the loop length is 4
for (var i = 0; i < featureLonLat.length; i++) {
/* actually:
featureLonLat[0] < containerLonLat[0] || featureLonLat[0] > containerLonLat[2]
featureLonLat[1] < containerLonLat[1] || featureLonLat[1] > containerLonLat[3]
featureLonLat[2] < containerLonLat[0] || featureLonLat[2] > containerLonLat[2]
featureLonLat[3] < containerLonLat[1] || featureLonLat[3] > containerLonLat[3]
*/
if (featureLonLat[i] < containerLonLat[i % 2] || featureLonLat[i] > containerLonLat[i % 2 + 2]) {
return false;
}
}
return true;
};
QyGIS.prototype.getInnerFeatures = function(layerName, extent) {
var self = this;
var layer = self.getLayer(layerName);
if (layer) {
var source = layer.getSource();
var features = source.getFeatures();
for (var i = 0; i < features.length; i++) {
var curFeatureExtent = features[i].getGeometry().getExtent();
if (self.isInner(curFeatureExtent, extent)) {
console.log(features[i].get('name') + 'in area');
}
}
}
};
At last, sorry for my poor english if my answer confuse you .
I had to use
var XY = ol.extent.applyTransform(extent, ol.proj.getTransform("EPSG:3857", "EPSG:4326"));
instead of
var XY = ol.proj.transform([long, lat], 'EPSG:4326', 'EPSG:3857');
and it works.
var imgOut = function(){
var outImg = Math.floor(Math.random()*slideRandom.length);
document.getElementById("random").src = imgRandom[outImg];
var outSlide = slideRandom[outImg];
outSlide();
var wr = Math.floor(Math.random()*imgRandom.length);
var btl = Math.floor(Math.random()*bottle.length);
document.getElementById("bottle2").src = bottle[outImg];
document.getElementById("bottle1").src = bottle[btl];
document.getElementById("bottle3").src = bottle[wr];
/* try below but doesn't work or syntax error occured*/
var position= ['bottle[outImg]','bottle[btl]','bottle[wr]'];
var pos = Math.floor(Math.random()*position.length);
var pos1 = position[pos];
pos1();
}
what I'm try to do is
with different arrays to get different each images in different random position.
I've done different images to get but with three different arrays to put in random position doesn't work. what have I done wrong? or how to change above code?
I don't understand your requirements exactly, but consider this code:
var setImage = function(id, src) {
document.getElementById(id).src = src;
};
var chooseOne = function(array) {
return array[Math.floor(Math.random()*array.length)];
};
var setRandomImages = function() {
setImage("bottle1", chooseOne(bottle));
setImage("bottle2", chooseOne(bottle));
setImage("bottle3", chooseOne(bottle));
};
If the array bottle is a list of URLs, this will do something, though I cannot guarantee it will do what you want.
var position= ['bottle[outImg]()','bottle[btl]()','bottle[wr]()'];
var pos = Math.floor(Math.random()*position.length);
var pos1 = position[pos];
//pos1();
eval( pos1 );
// or
(new Function("return pos1"))();