1

I am using the following codes to visualize a GeoJSOn on Google Maps API.

var geojsonFeature = {
                                    "type": "Feature",
                                    "geometry": {
                                      "type": "Polygon",
                                      "coordinates": JSON.parse(JSONobject[0].JSON).coordinates[0]
                                    }
                            };
                            var googleOptions = {
                                strokeColor: "#FFFF00",
                                strokeWeight: 7,
                                strokeOpacity: 0.75
                            };

                            var myGoogleVector = new GeoJSON(geojsonFeature, googleOptions);

                            if (myGoogleVector.error){
                                // Handle the error.
                            }else{
                                myGoogleVector.setMap(map);
                            }

Its returning the following error

uncaught reference error GeoJSON is not defined

here is the GeoJSON fetching from database

[[[[-3.58466299999998,40.653534],[-3.58416399999999,40.645122],[-3.57777099999998,40.645808],[-3.56814799999995,40.643543],[-3.56669199999999,40.650369],[-3.55906599999997,40.650485],[-3.562074,40.645539],[-3.55856,40.642499],[-3.55641499999996,40.636165],[-3.56240699999995,40.637156],[-3.56385,40.634403],[-3.56028999999995,40.62432],[-3.55866899999995,40.624382],[-3.559326,40.612243],[-3.55188399999997,40.611541],[-3.54740999999996,40.613852],[-3.54317099999997,40.612906],[-3.53588499999995,40.616672],[-3.52996099999996,40.613629],[-3.52470799999998,40.614486],[-3.52360699999997,40.616052],[-3.51882999999998,40.615856],[-3.50475,40.62025],[-3.50232199999999,40.619824],[-3.50347599999998,40.625645],[-3.49253299999998,40.624856],[-3.486874,40.625408],[-3.48826199999996,40.61937],[-3.48614299999997,40.615703],[-3.47918699999997,40.613561],[-3.47633099999996,40.609201],[-3.47601399999996,40.604547],[-3.46338799999995,40.607617],[-3.457448,40.606575],[-3.45370599999995,40.60743],[-3.46489399999996,40.598167],[-3.46592699999997,40.595318],[-3.46756299999998,40.595986],[-3.47589299999999,40.59241],[-3.482843,40.587501],[-3.48226799999998,40.586469],[-3.48881599999999,40.58506],[-3.49518,40.585953],[-3.50831399999998,40.58232],[-3.52083099999999,40.581192],[-3.52729499999998,40.582836],[-3.52976099999995,40.582188],[-3.52989299999996,40.58424],[-3.53294899999997,40.58501],[-3.54014899999999,40.583977],[-3.53991399999995,40.582635],[-3.545323,40.583943],[-3.54951199999999,40.587284],[-3.55304899999999,40.586448],[-3.56139099999996,40.587875],[-3.561644,40.592727],[-3.56544099999996,40.592964],[-3.56566199999997,40.598347],[-3.57579699999997,40.601903],[-3.57759999999996,40.607995],[-3.57447999999999,40.610901],[-3.573981,40.618885],[-3.57977899999997,40.619304],[-3.58072199999998,40.623112],[-3.58449400000001,40.627281],[-3.58942199999996,40.633644],[-3.59164399999997,40.640263],[-3.58941299999998,40.644885],[-3.59190799999999,40.648937],[-3.59346299999999,40.654804],[-3.58933299999995,40.655884],[-3.58466299999998,40.653534]]]]
  • do you have a source for the geojson? (how was it created) – Mapperz Jul 30 '13 at 13:35
  • I have updated my question with GeoJSON values fetching by PHP and Ajax – Devils Dream Jul 30 '13 at 17:29
3

I used this web to validate GeoJSON: http://geojsonlint.com/

After pasting yours, I got:

Invalid GeoJSON
POSTed data was not JSON serializeable.

Try this link to test all your GeoJSON files to see where is the error.

Hope this helps,

  • I have updated my question with GeoJSON values fetching by PHP and Ajax – Devils Dream Jul 31 '13 at 5:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.