Google Maps API and WMS Servers

    技术2022-05-11  72

    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 variables2) The URL to the WMS Server, don’t forget the “?” at the end3) Name of service, used for labeling4) 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 expecting5) Style – the WMS style to use. See 4.6) Format – the image format to return. (e.g. image/png, image/jpeg etc.)

     

    最新回复(0)