How can the user be redirected if he clicks on a marker in CartoDB?
I have a dataset with the markers —*the geometry and inside of the description-field the URL to redirect the user. I know I can redirect the user by calling on('featureClick') and then change the window.location …*but how can I change the window.location to set it to the description-value of my dataset? I've tried with sql.execute but failed (Access-Control-Allow-Origin………). Any Ideas?
My Example: (not working)
var d = layers[1].getSubLayer(2),d.setInteraction(true);d2.on('featureClick', function(e, latlng, pos, data) { cartodb.log.log(data.cartodb_id); var sql = new cartodb.SQL({ user: 'cartodb_user' }); sql.execute("SELECT description FROM mytable WHERE cartodb_id = "+data.cartodb_id) .done(function(data) {console.log(data.rows)}) .error(function(errors) {console.log("errors:" + errors)}) //var url = description; //window.location = url; });
أكثر...
I have a dataset with the markers —*the geometry and inside of the description-field the URL to redirect the user. I know I can redirect the user by calling on('featureClick') and then change the window.location …*but how can I change the window.location to set it to the description-value of my dataset? I've tried with sql.execute but failed (Access-Control-Allow-Origin………). Any Ideas?
My Example: (not working)
var d = layers[1].getSubLayer(2),d.setInteraction(true);d2.on('featureClick', function(e, latlng, pos, data) { cartodb.log.log(data.cartodb_id); var sql = new cartodb.SQL({ user: 'cartodb_user' }); sql.execute("SELECT description FROM mytable WHERE cartodb_id = "+data.cartodb_id) .done(function(data) {console.log(data.rows)}) .error(function(errors) {console.log("errors:" + errors)}) //var url = description; //window.location = url; });
أكثر...