I'm working on a multiple query with Fusion Table. Till yesterday I used numericID but today creating a new Table, FT shows no numeric ID in the about menu. I tried to change NUmeric ID with Ecrypted one, but it doesn't work. This is the page:
http://siti-torino.hostei.com/test/test_09_02.html ( numeric ID)
http://siti-torino.hostei.com/test/test_09_03.html ( Encrypted ID)
It's quite clear that the query works correctly (the counter show the right result), but the script can't update the map. So I suppose the problem is at line 94-95
searchTracks = new google.maps.FusionTablesLayer(fusionTableId, { query: searchStr});
What am I doing wrong here?
You are using the "old syntax", that doesn't work with encrypted ids.
new google.maps.FusionTablesLayer(fusionTableId, { query: searchStr});
Use the documented syntax
new google.maps.FusionTablesLayer({ query: {[FusionTablesQuery object](https://developers.google.com/maps/documentation/javascript/reference#FusionTablesQuery)}});
Example of your page
Hey Guys I'm trying to pick up the piece after a coworker left. I'm not a programmer.
We beleive the site might be having a problem not recognizing the new I'ds as a String compared to the old numeric Values
//Setting the lat lng
var latlng = new google.maps.LatLng(lati, long);
var myOptions = {
zoom: zoomLevel,
center: latlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
map.setOptions(myOptions);
layer = new google.maps.FusionTablesLayer "1QzYXB7nkb7drbz66HMmq3_d7Dut_Gulx2aZEC2Q";
layer.setMap(map);
if(addressMarker)
addressMarker.setMap(null);
addressMarker = new google.maps.Marker({
map: map,
position: latlng
});
infowindow.open(map,addressMarker);
google.maps.event.addListener(addressMarker, 'click', function()
{
infowindow.open(map,addressMarker);
});
}
}
Related
I am working with two collections of satellite data. I want to select specific bands from "collection 1", join them to "collection 2", and then run a function. Unfortunately, the function does not work with the joined data, although it works for "collection 1".
Here is an example just using B10 of Sentinel-2
//identifying area and date
var geometry = ee.Geometry.Point([4,45]);
Map.centerObject(geometry,10);
var start = '2019-03-10';
var end = '2019-05-10';
//my function
function testing(img){
img = img.updateMask(img.select(['B10']).gt(200).focal_min(2).focal_max(2).not());
return img;
}
//my two collections
var collection1 = ee.ImageCollection('COPERNICUS/S2').filterDate(start,end)
.filterBounds(geometry);
var B10s=collection1.select('B10');
//print('B10s',B10s);
var collection2 = ee.ImageCollection('COPERNICUS/S2_SR')
.filterDate(start,end)
.filterBounds(geometry);
// joining the collections
var filtering = ee.Filter.equals({
leftField: 'system:time_start',
rightField: 'system:time_start'
});
var simpleJoin = ee.Join.inner();
var innerJoin = simpleJoin.apply(collection2, B10s, filtering);
var joined = innerJoin.map(function(feature) {
return ee.Image.cat(feature.get('primary'), feature.get('secondary'));
});
print('Joined', joined);
//just to visualize one image
//var coll1 = ee.Image(collection1.first());
//Map.addLayer(coll1, {bands:['B2'], min:0, max:5000},'B2Coll1 test');
//running the function for collection 1 works
var test = collection1.map(testing);
var tess = ee.Image(test.first());
Map.addLayer(tess, {bands:['B2'], min:0, max:5000},'B2 test');
//here when running with the joined collection, there is a problem
var TestingJoined = joined.map(testing);
The error is: img.select(...).gt is not a function
How do I make this work?
When you debug, does the join work as intended? Is there any issue with the datetimes being too-precise to allow a full join?
The second route I would go down is ensuring that the joined object is identical to collections. I doubt this would be the case without you casting it or something (though I'm not familiar with this library). Your "testing" function that you're mapping to these collections may work with just the unjoined ones. If you provide the actual 'Problem' or error output that would be immensely helpful.
Ok. I solved it. Thank you for your input.
I needed to use a cast in the function. Now it works.
function testing(img){
img = ee.Image(img).updateMask(ee.Image(img).select(['B10']).gt(200).focal_min(2).focal_max(2).not());
return img;
}
I took a look at the postgresql driver dokumentation. I found the following code there.
conn.query('select color from crayons where id = #id', {'id': 5})
.toList()
.then((result) { print(result); });
conn.execute('insert into crayons values (#id, #color)',
{'id': 1, 'color': 'pink'})
.then((_) { print('done.'); });
I wanted to test the inserting of the id into the string and put the following code into try.dart.org
// Go ahead and modify this example.
void main() {
var string = 'select color from crayons where id = #id', {'id': 5};
print(string);
}
Unfortunately this gives me the following error Compilation failed: Expected identifier, but got '{'.. I also tried a few abbreviations but nothing helped.
So the question is. How do I properly insert the values of a map into a string?
Your example code from the PostgreSQL driver means that the query() method expects two arguments, a string and a map.
Your 2nd example seems to try to do string interpolation. In Dart this would look like
var id = 5;
var string = 'select color from crayons where id = $id'; // or ${id}
print(string);
Please don't try this for SQL. This opens a big hole for SQL injection attachs.
PostgresSQL does it's own string interpolation in a safe way.
A fusion table has stopped being shown via the Maps API. It was working the other day (Monday or last Friday).
It works fine inside the Fusion Tables website.
Other fusion tables continue to work fine via the Maps API.
Here's a site I made showing the (actually not showing the) layer in question.
http://dl.dropboxusercontent.com/u/14878119/map/sewerlayernotshowing.html
View the source of that site for the entire code, but here's how this layer (and all the others we use) are being called:
<script>
//initializing Google Maps
map = new google.maps.Map(document.getElementById('divMap'), {
zoom: 14,
center: {lat:33.040171488300871,lng:-97.022509084376622}
});
//Fusion Table (Sewer Lines) *****NOT WORKING!*****
var _ftId = "140ge-x0HKkzrlZYOdrCxYBNlu4ta15vpHetZh_s";
var _ft = new google.maps.FusionTablesLayer(_ftId,{query: "SELECT * FROM " + _ftId});
_ft.setMap(map);
//Fusion Table (Sewer Points) *****WORKING*****
var _ftId2 = "1NsByxnFPfr20fL1MAr_zYoPdtocKqCXJg9tqLoA";
var _ft2 = new google.maps.FusionTablesLayer(_ftId2,{query: "SELECT * FROM " + _ftId2});
_ft2.setMap(map);
</script>
Any ideas why the one with id 140ge-x0HKkzrlZYOdrCxYBNlu4ta15vpHetZh_s would stop working?
You are using the "old" (now undocumented) syntax for FusionTableLayer constructors. Use the new syntax and it works.
//Fusion Table (Sewer Lines)
var _ftId = "140ge-x0HKkzrlZYOdrCxYBNlu4ta15vpHetZh_s";
var _ft = new google.maps.FusionTablesLayer({
query: {
select: "Shape",
from: _ftId,
where: ""
},
options: {
styleId: 6,
templateId: 2
}
});
_ft.setMap(map);
working fiddle
Just wondering am I doing this correctly or is there a better way.
I have 3 tables, Game, User and UserGame. The UserGame is a join table has pointers to both Game and User tables.
The following script returns all the games that the user has joined.
var Game = Parse.Object.extend("Game");
var UserGame = Parse.Object.extend("UserGame");
var innerQuery = new Parse.Query(Game);
var query = new Parse.Query(UserGame);
query.equalTo("user", user);
query.matchesQuery("game", innerQuery);
query.include("game");
query.find({
I am now trying to return the games that the user has not joined. I tried the reverse of the above query but it does not work. Any ideas?
Also is there a better solution than using the join table above, should I just add a list of game pointers to the user table?
This is userful (and not easily accessible from the website)
https://parse.com/docs/js/symbols/Parse.Query.html
What you're trying to do seems like a good usecase of .noContainerIn([results of the first query]) or .doesNotMatchKeyInQuery
matchesKeyInQuery in your first example seems simpler to use BTW
I have used a table that has two pointers inside it too.I'm going to explain what I did simplified, and adpating it to your case:
1.Build a query with your object Game,to get an array of all games that exists in this table:
var Game = Parse.Object.extend("Game");
var query = new Parse.Query(Game);
query.find({
success: function(arrayGames) {
//store this array to manage later
},
error: function(user, error) {
alert("There is not stored games");
}
});
2. Get the user you want to compare to this games stored that points in the table UserGame, and make a Query for each element of the previous got array:
var UserGame = Parse.Object.extend("UserGame");
var query = new Parse.Query(UserGame);
var currentUser = Parse.User.current();
var currentGame;
for(var i=0; i<arrayGames.length ;i++){
currentGame=arrayGames[i];
query.equalTo("Game", currentGame);
query.notEqualTo("User", currentUser);
query.find({
success: function(foundGames) {
//you have got an array with the games not joined to this user
},
error: function(user, error) {
alert("There are not joined games ");
}
});
}
Hope it helps, ask me if you need more details ;)
i am facing a problem in the nerddinner, what i am facing:
in the DinnerForm.ascx there is a javascript code
$(document).ready(function () {
NerdDinner.EnableMapMouseClickCallback();
$("#Dinner_Address").blur(function (evt) {
//If it's time to look for an address,
// clear out the Lat and Lon
$("#Dinner_Latitude").val("0");
$("#Dinner_Longitude").val("0");
var address = jQuery.trim($("#Dinner_Address").val());
if (address.length < 1)
return;
NerdDinner.FindAddressOnMap(address);
});
});
when i run the project, and i insert new Dinner, the longitude and the latitude inserted with value 0;
and when i changed the "0" to any number
$(document).ready(function () {
NerdDinner.EnableMapMouseClickCallback();
$("#Dinner_Address").blur(function (evt) {
//If it's time to look for an address,
// clear out the Lat and Lon
$("#Dinner_Latitude").val("12");//
$("#Dinner_Longitude").val("12");//
var address = jQuery.trim($("#Dinner_Address").val());
if (address.length < 1)
return;
NerdDinner.FindAddressOnMap(address);
});
});
it inserts the value 12 for both long and lat to the database
so i knew its inserting this value to the database, but am not sure actually
so i really want to know how i can fix this, plz any one :D
Look in Scripts/NerdDinner.js for this block of code:
//If we've found exactly one place, that's our address.
//lat/long precision was getting lost here with toLocaleString, changed to toString
if (NerdDinner._points.length === 1) {
$("#Latitude").val(NerdDinner._points[0].Latitude.toString());
$("#Longitude").val(NerdDinner._points[0].Longitude.toString());
}
The problem appears to be that this script tries to set the values for elements named Latitude and Longitude, but in Views\Dinners\DinnerForm.ascx, those element ids are resolved as Dinner_Latitude and Dinner_Longitude, respectively. As a workaround, you should be able modify two lines in NerdDinner.js so it would update either element it finds:
if (NerdDinner._points.length === 1) {
$("#Latitude,#Dinner_Latitude").val(NerdDinner._points[0].Latitude.toString());
$("#Longitude,#Dinner_Longitude").val(NerdDinner._points[0].Longitude.toString());
}
My problem was that none of the values in the edit page were persisted. It was an issue in DinnersController.cs.
I changed
UpdateModel(dinner, "Dinner");
to
UpdateModel(dinner);
It seemed that the problem was that the controller code was expecting keys named Dinner.Id, Dinner.Title, etc. but the keys were actually named just Id and Title (etc.).