Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I solved the problem by using the json call method. Code below.</p> <pre><code> &lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;meta charset="UTF-8"&gt; &lt;title&gt;David's Build Up&lt;/title&gt; &lt;link href="./stylesheets/example.css" media="screen" rel="stylesheet" type="text/css" /&gt; &lt;link rel="shortcut icon" href="/images/favicon.ico" /&gt; &lt;noscript&gt;&lt;meta http-equiv="refresh" content="0;url=/no_javascript.html"&gt;&lt;/noscript&gt; &lt;!-- Find box coordinates javascript --&gt; &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"&gt; &lt;/script&gt; &lt;script type ="text/javascript" src="http://www.movable-type.co.uk/scripts/latlon.js"&gt;&lt;/script&gt; &lt;!-- Type label text javascript --&gt; &lt;script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="./js/label.js"&gt;&lt;/script&gt; &lt;!-- Visulization javascript --&gt; &lt;script type="text/javascript" src="http://www.google.com/jsapi"&gt;&lt;/script&gt; &lt;!-- Initialize visualization --&gt; &lt;script type="text/javascript"&gt; google.load('visualization', '1', {}); &lt;/script&gt; &lt;script type="text/javascript"&gt; function drawBox(topleftx, toplefty, bottomrightx, bottomrighty) { var bounds = new google.maps.LatLngBounds( new google.maps.LatLng( topleftx, toplefty ), new google.maps.LatLng( bottomrightx, bottomrighty ) ); var overlay = new google.maps.Rectangle({ map: carto_map, bounds: bounds, strokeColor: "#0000ff", strokeOpacity: 0.20, strokeWeight: 2, fillColor: "#0000ff", fillOpacity: 0.050, }); } function initialize() { // Set the map parameters var cartodbMapOptions = { zoom: 5 , center: new google.maps.LatLng( 40.313043, -97.822266 ), mapTypeId: google.maps.MapTypeId.ROADMAP } // Initialize the map carto_map = new google.maps.Map(document.getElementById("map"),cartodbMapOptions); // Query to grab the data var query = "SELECT Latitude, Longitude, Impressions FROM " + '[encrypted table ID here]'; var encodedQuery = encodeURIComponent(query); // Construct the URL to grab the data var url = ['https://www.googleapis.com/fusiontables/v1/query']; url.push('?sql=' + encodedQuery); url.push('&amp;key=AIzaSyAm9yWCV7JPCTHCJut8whOjARd7pwROFDQ'); url.push('&amp;callback=?'); // Set the number of rows var numRows = 3500; // Get the variables from the table, in a loop $.ajax({ url: url.join(''), dataType: 'jsonp', success: function (data) { var rows = data['rows']; var ftData = document.getElementById('ft-data'); for (var i in rows) { var centerX = rows[i][0]; var centerY = rows[i][1]; var imps = rows[i][2]; // Set the center points var centerPoint = new LatLon(centerX,centerY); var latLng = new google.maps.LatLng(centerX,centerY); // Set top left points var toplefty = centerPoint.destinationPoint(-45, 6)._lon; var topleftx = centerPoint.destinationPoint(-45, 7.7)._lat; // Set bottom right points var bottomrighty = centerPoint.destinationPoint(135, 6)._lon; var bottomrightx = centerPoint.destinationPoint(135, 7.7)._lat; // Draw the box drawBox(topleftx, toplefty, bottomrightx, bottomrighty); // Drop markers var marker = new google.maps.Marker({ position: latLng, draggable: false, markertext: imps, flat: true, map: carto_map }); var label = new Label({ map: carto_map, position: latLng, draggable: true }); label.bindTo('text', marker, 'markertext'); marker.setMap(null); }; } }); } &lt;/script&gt; &lt;/head&gt; &lt;body onload="initialize()"&gt; &lt;div id="map"&gt;&lt;/div&gt; &lt;div id="ft-data"&gt;&lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload