Google Maps – Properly Displaying a Polygon

google mapspolygonrenderingsql server

NOTE: this question is sorta like a follow-on question to this original GIS Question I asked. In that question, the main suggestion was that I was trying to show two polys. Now, I'm asking about a SINGLE poly.

I have the following GEOGRPAHY of Los Angeles in my Sql Server 2008 :-

enter image description here

Sql script to repo it (or in RAW sql format)

It's bascially ..

-- Shape of Los Angeles.

DECLARE @WKT VARCHAR(MAX) = 'POLYGON ((-118.66815700000011 34.181235000000029, ... ))
SELECT GEOGRAPHY::STGeomFromText(@WKT, 4326)

Now when I just try and render this out, It now looks like this (NOTE: this is different, but still not correct .. compared to my previous GIS Question).

enter image description here

Now, in the previous question people were suggesting that the previous data was a MULTIPOLYGON so there was some bad stuff I must have been doing, trying to render out holes in polys.

This time, this is a single polygon. So i'm assuming the hole theory still doesn't work. Now, I understand that by looking at this image, there's a number of holes … but the Well Known Text data which Sql Server gives me is a POLYGON which to me means .. one single shape. So i'm not sure how I can fix this 🙁

This is why i'm asking the a similar question to my previous one.

Can anyone help? Can they see the data I've posted and see what happens in other systems? (I don't have any other software besides Sql Server 2008).

Maybe I need to extract all my data from Sql Server 2008 .. and clean it up (whatever that means) through another system. For example. If Sql Server is saying that the shape of Los Angeles is a single Polygon .. but when cleaned up .. it's actually 7 Polygons .. and then those shapes then get rendered correctly .. then we have a solution!

Any suggestions?

Can -anyone- render this shape onto a Google map?

Best Answer

I was able to get this to work: http://dl.dropbox.com/u/2654618/la_goog.html

Here's a screenshot: enter image description here

As I said in my comment, I reformatted your raw data. I did this with some python and a little hand-jamming. The resulting JSON is here: http://dl.dropbox.com/u/2654618/la_geom.json That's the Esri JSON format for a polygon. The link above converts the geometry from the Esri JSON format to the Google format, which is a two dimensional array.

It seems like there's a problem converting the response from SQL Server to the two dimensional array that Google expects. I would look at your code doing that conversion.

Related Question