Note that there are some explanatory texts on larger screens.

plurals
  1. POjson object with array of arrays
    text
    copied!<p>I am trying to create two polygons on a google map using the google map API.</p> <p>I am getting the following error:</p> <blockquote> <p>Error: Invalid value for constructor parameter 0: -94.963194,39.316858,-94.95967,39.32199,-94.95905,39.32172,-94.95846,39.3214,-94.95792,39.32104,-94.95742,39.32064,-94.95698,39.32021,-94.95625,39.31927,-94.95599,39.31876,-94.95578,39.31824,-94.95564,39.3177,-94.95557,39.31716,-94.95557,39.31661,-94.963194,39.316858</p> </blockquote> <p>I hope someone can help explain what I am doing wrong and kindly offer a resolution.</p> <pre><code>&lt;script src="https://maps.googleapis.com/maps/api/js?sensor=false&amp;libraries=visualization"&gt; &lt;/script&gt; &lt;script&gt; var map; function initialize() { var kansas_city = new google.maps.LatLng(39.00495613,-94.64780668); var mapOptions = { zoom: 10, center: kansas_city, mapTypeId: google.maps.MapTypeId.TERRAIN }; map = new google.maps.Map(document.getElementById('map_canvas'), mapOptions); // Create a &lt;script&gt; tag and set the USGS URL as the source. var script = document.createElement('script'); script.src = 'sector.json'; document.getElementsByTagName('head')[0].appendChild(script); } // Loop through the results array and place a marker for each // set of coordinates. window.sector_callback = function(results) { for (var i = 0; i &lt; results.features.length; i++) { var coords = results.features[i].geometry.coordinates; alert(coords); var polygons = new google.maps.Polygon({ path: coords, map: map }); } } &lt;/script&gt; </code></pre> <p>JSON code:</p> <pre><code>sector_callback({ "type": "FeatureCollection", "features": [{ "type": "Feature", "properties": { "Name": "1_1", "Description": "" }, "geometry": { "type": "Polygon", "coordinates": [ [ [-94.963194, 39.316858], [-94.959670, 39.321990], [-94.959050, 39.321720], [-94.958460, 39.321400], [-94.957920, 39.321040], [-94.957420, 39.320640], [-94.956980, 39.320210], [-94.956250, 39.319270], [-94.955990, 39.318760], [-94.955780, 39.318240], [-94.955640, 39.317700], [-94.955570, 39.317160], [-94.955570, 39.316610], [-94.963194, 39.316858] ] ] } }, { "type": "Feature", "properties": { "Name": "214_1", "Description": "" }, "geometry": { "type": "Polygon", "coordinates": [ [ [-94.783917, 39.083417], [-94.776470, 39.084670], [-94.776340, 39.084140], [-94.776290, 39.083590], [-94.776300, 39.083040], [-94.776380, 39.082500], [-94.776530, 39.081960], [-94.777020, 39.080940], [-94.777360, 39.080460], [-94.777760, 39.080000], [-94.778210, 39.079570], [-94.778710, 39.079180], [-94.779260, 39.078830], [-94.783917, 39.083417] ] ] } }] }); </code></pre>
 

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