Help: how to overlay a .shp map layer to google map?

435 views
Skip to first unread message

Bill

unread,
Aug 17, 2009, 5:53:24 PM8/17/09
to Google Maps JavaScript API v3
Greetings everyone,

I'm new here. I have a question regarding how to overlay a .shp file
to goolge maps. I have a .shp file with about 50 polygons inside. Most
polygons have over 2000 vertices. Now, I want to overlay this polygon
layer to the goole map in my intranet website. Anybody could give me
any advice or show some demo code?

Thanks a lot in advance for any responses!

Bill

mapperzUK

unread,
Aug 18, 2009, 8:45:09 AM8/18/09
to Google Maps JavaScript API v3
Is this a v3 question or v2 question?
v3 does not support overlays (currently)

v2 does support geoxml.
Though you best bet is to convert .shp to .kml
then you can use geoxml to overlay your data.
though you might find it limiting.
There are other third party geoxml scripts that are currently bett
than google own.

A very good link is:
http://econym.org.uk/gmap/egeoxml.htm
(Credit to Mike Williams)

I have seen a couple google mashups that do overlay .shp files, but
are slow to perform
or don't do what you expect with your data.


Mapperz
http://mapperz.blogspot.com/

bratliff

unread,
Aug 18, 2009, 10:45:14 AM8/18/09
to Google Maps JavaScript API v3
I am developing "Light Weight Polys" for V3. It can handle much
larger polys than GPoly for V2. It is a lot faster dragging, panning
& zooming. 50 polys with 2000 vertices per poly are quite manageable.

Look at:

www.polyarc.us/polycluster

A few extreme examples:

20,000 vertices
www.polyarc.us/polycluster/canada.html

14,000 vertices
www.polyarc.us/polycluster/alaska.html

41,000 vertices
www.polyarc.us/polycluster/absurd.html

Unfortunately, Internet Explorer does not support CANVAS which means
it is unsupported for now. I may add VML support if people request
it.

If it works for you, I will be glad to assist you converting your
shape files to the following format:

var whatever=
{
poly0:
[
[
{x:lon,y:lat},
. . .
{x:lon,y:lat},
]
,
[
{x:lon,y:lat},
. . .
{x:lon,y:lat},
]
]
,
poly1:
[
[
{x:lon,y:lat},
. . .
{x:lon,y:lat},
]
,
[
{x:lon,y:lat},
. . .
{x:lon,y:lat},
]
]
}
;

For an actual example, look at:

http://polyarcs.googlepages.com/st26.raw

If you run "shp2text" on each of your shape files, zip the results,
post an on-line link (no email attachments please), I will do the
conversion for you.

I am trying to promote "Light Weight Polys" without much luck. A
happy user will help.

bratliff

unread,
Aug 18, 2009, 10:50:44 AM8/18/09
to Google Maps JavaScript API v3
On Aug 18, 2:45 pm, bratliff <bratl...@umich.edu> wrote:

OOPS - I gave you an obsolete link. Try:

http://polyarcs.googlepages.com/ca.raw

lonniga

unread,
Aug 20, 2009, 10:34:56 AM8/20/09
to Google Maps JavaScript API v3
I would be interested to see it work in IE since most of my clients
(e.g RedCross, NatGuard) are using IE and have no control about what
IT allows on their machines.

Sheng Wang

unread,
Aug 22, 2009, 10:24:26 PM8/22/09
to google-map...@googlegroups.com
Thank you all so much for your responses. 

I tried in v2 using web service to convert my .shp file to a json point file, and draw them in GPoly. It did not work for too much points in one polygon. Thank mapperzUK's idea of using .kml file. 


It looks Bratliff has given an exciting solution for this issue. I'll try it. Thank you very much for your help again. I'll let you know my result. 

Bill
--
Sheng Wang

mapperzUK

unread,
Aug 23, 2009, 4:34:14 PM8/23/09
to Google Maps JavaScript API v3
Bratliff has done some excellent work on making the overlay of data
possible for v3.
well done. looks very promising for large vector overlays.
Though only for Canvas (Firefox etc), though not IE VML support.
Not that any in the Google Maps groups use IE, lots do out there
still.
Will be using Bratliff code for vector generating from a database at
some point soon.

Mapperz
http://mapperz.blogspot.com/

bratliff

unread,
Aug 23, 2009, 5:00:29 PM8/23/09
to Google Maps JavaScript API v3
On Aug 23, 8:34 pm, mapperzUK <mapp...@googlemail.com> wrote:
> Bratliff has done some excellent work on making the overlay of data
> possible for v3.
> well done. looks very promising for large vector overlays.
> Though only for Canvas (Firefox etc), though not IE VML support.
> Not that any in the Google Maps groups use IE, lots do out there
> still.
> Will be using Bratliff code for vector generating from a database at
> some point soon.
>
> Mapperzhttp://mapperz.blogspot.com/

I am making some performance improvements to combine several polys
into single tiled CANVAS elements. I am not sure it can be ported to
VML but I am very willing to help anyone who would like to try.
CANVAS is supported by Firefox, Safari, Opera, Chrome & iPhone. I am
aware of two efforts to give CANVAS capability to Internet Explorer
despite Microsoft's resistance - one by Mozilla - the other by
Google. Microsoft would prefer people would use their junk. Remember
Visual Basic ?

bratliff

unread,
Aug 25, 2009, 8:30:27 PM8/25/09
to Google Maps JavaScript API v3
I have made some changes to conserve memory - more polys with fewer
CANVAS elements. The internal cache consumes half of the memory it
did.

I have added poly inversion to one of the examples. Try:

www.polyarc.us/polycluster

Click "Reverse" toggle the polys.

Sheng Wang

unread,
Aug 25, 2009, 8:40:46 PM8/25/09
to google-map...@googlegroups.com
It works amazingly good in Chrome. Hope one day the IE version will come. 

Thanks a lot for your work!
--
Sheng Wang

bratliff

unread,
Aug 26, 2009, 5:45:06 AM8/26/09
to Google Maps JavaScript API v3

On Aug 26, 12:40 am, Sheng Wang <shen...@gmail.com> wrote:
> It works amazingly good in Chrome. Hope one day the IE version will come.
> Thanks a lot for your work!

Thanks very much for the feedback. I have no idea whether people are
actually using it.

Porting it to VML will be difficult without a replacement for the
"globalCompositeOperation". I will be glad to help anyone who would
like to try to port it to Internet Explorer. I am aware of a couple
of CANVAS to VML translators but their performance is poor. I believe
Mozilla is working on an actual CANVAS "plug-in" for Internet
Explorer. Of course, Microsoft would prefer to promote their own
junk.

Esa

unread,
Aug 26, 2009, 6:18:29 AM8/26/09
to Google Maps JavaScript API v3


On Aug 26, 12:45 pm, bratliff <bratl...@umich.edu> wrote:

>  I am aware of a couple
> of CANVAS to VML translators but their performance is poor.  I believe
> Mozilla is working on an actual CANVAS "plug-in" for Internet
> Explorer.  

There is also explorercanvas project in Google Code:
http://code.google.com/p/explorercanvas/

> Of course, Microsoft would prefer to promote their own
> junk.

Silverlight

bratliff

unread,
Aug 26, 2009, 6:50:17 AM8/26/09
to Google Maps JavaScript API v3
Hi Esa,

"explorercanvas" is one of the two translators I was referring to.
The other is by Emil Eklund

http://me.eae.net/archive/2005/12/29/canvas-in-ie/

I am looking for help to do the port to Internet Explorer. Is
Silverlight worth considering ?
Reply all
Reply to author
Forward
0 new messages