Google Maps API and WMS Servers

Google Maps API and WMS Servers

James Fee and others have pointed out that Cubewerks is offering an add-on to their server product that offers Google Maps data as a WMS service. This is pretty cool but what I’d expect most developers want is the ability to display WMS layers directly in a GMap instance in the browser. Fortunately, this is not too difficult if we base a WMS map spec on the existing Street Map spec and then manipulate the URL returned for each map tile. IMO, this opens up a lot more data for use in simple GMaps applications.

UPDATE (3/27/06) - There is a better working version for Google Maps V2 here: http://johndeck.blogspot.com/

Download the WMSSpec code (updated to version 0.4)

UPDATE - Based on feedback, I changed the spec a bit. You don't have to pass in a base spec anymore and the shortname, version, copyright, SRS, BackgroundColor and Transparency values can now be optionally set in the constructor. Also, you can set the OverlaySpec property to any map spec you want and it will use the new GM overlay code. YMMV.

UPDATE 2 (8/9/05) - One quick change, when the Spec you use for your overlay already has an overlay (e.g. Hybrid), it now uses the overlay instead of the base spec. This allows you to put the Hybrid streets over any WMS layer

New Example for 0.4:
var wms = new WMSSpec("http://wms.jpl.nasa.gov/wms.cgi?", "WMS Test", "WMS", "modis", "default", "image/jpeg", "NASA 2005");
wms.OverlaySpec = map.mapTypes[2];     //Hybrid map streets


Example:
var wms = new WMSSpec(mapTypes[0], "http://wms.jpl.nasa.gov/wms.cgi?", "WMS Test", "modis", "default", "image/jpeg" );
Either add this to your array of specs passed to the GMap constructor or use the undocumented access to the array itself. (MyGMap.mapTypes[MyGMap.mapTypes.length] = wms;)

WMSSpec(baseSpec, baseURLtoWMSServer, name, layer, style, format);
1) the Google Maps Streets spec, usually the first spec in the array but it is also pointed to by the G_MAP_TYPE and _GOOGLE_MAP_TYPE variables
2) The URL to the WMS Server, don’t forget the “?” at the end
3) Name of service, used for labeling
4) Layer – the WMS layer name to use. This parameter is passed in whole to the server so it will accept whatever the WMS server is expecting
5) Style – the WMS style to use. See 4.
6) Format – the image format to return. (e.g. image/png, image/jpeg etc.)

 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值