WMS in Google Maps
As a follow up to my previous tutorial on how to use your own custom map tiles in Google Maps, here’s the code (function) you need to convert Google tile x, y, and zoom into a suitable WMS URL. Just stick this code in the getTileURL(x, y, zoom) or getOverlayURL(x, y, zoom) functions and tweek some of the parameters to your needs.
var baseURL = "http://localhost/cgi-bin/mapserv?"; //begining of the WMS URL ending with a "?" or a "&".
var format = "image/jpeg"; //type of image returned
var layers = "example_layer"; //WMS layers to display
var styles = ""; //styles to use for the layers
var srs = "EPSG:4326"; //projection to display. Don't change unless you know what you are doing.
var ts = this.tileSize;
var ul = this.getLatLng(x*ts,(y+1)*ts, zoom);
var lr = this.getLatLng((x+1)*ts,y*ts, zoom);
var bbox = ul.x + "," + ul.y + "," + lr.x + "," + lr.y;
var url = baseURL + "version=1.1.1&request=GetMap&Layers=" + layers + "&Styles=" + styles + "&SRS="+ srs +"&BBOX=" + bbox + "&width=" + ts +"&height=" + ts + "&format=" + format + "&transparent=true";
return url;
September 16th, 2005 at 11:28 am
Great work!
See also http://www.geoskating.com/gmap and my blog http://www.justobjects.org/blog/index.php?p=14 . I basically formalized your solution (and from Brian Flood http://www.spatialdatalogic.com/cs/blogs/brian_flood/archive/2005/07/11/39.aspx) into a function.
best,
Just
October 21st, 2005 at 7:35 am
Thanks for the email Kyle. This is good stuff and does address my comment in the previous installment. I wonder though, if it would be possible for just a few more comments through the code?
February 21st, 2006 at 11:01 am
hi kyle my aim is to connect Map server and google API for my Indian data.If there is any source code available kindly send me please…if full source code available it would be helpful…
March 11th, 2006 at 1:16 pm
How’s about geocode and routing function?
Can we submit their data?
Thanks
March 11th, 2006 at 2:08 pm
Kha,
What about geocode and routing? The Google Maps API doesn’t provide that service.
What do you mean by “submit their data”. Who’s they, and where are we submitting it?
-Kyle
March 13th, 2006 at 4:49 am
Hi Kyle,
I see geocode and routing functions are supported by maps.google.com. Can we implement for unsupported areas?
In WMS example (Kyle and Just), the overlay layer will hide G’s layers. I see G’s Road layer in Kyle’s but no G’s layer in Just’s. My map http://naman.dyndns.org:8080/map1.html also hide G’s.
Could we mix them?
Thanks
March 17th, 2006 at 11:30 am
Experimenting With Web Map Services for Google Maps
Viewing map images from Web Map Services (WMS) servers is a useful extension to the Google Maps API. It lets you present more than just geographical data. Now you can present weather maps or vegetation maps and lads of other topics.
July 19th, 2006 at 10:48 pm
sir at d very begining of ur tutorial u hv mentioned dat u ;ll assume dat 1 would knw dat how 2 make a function dat can get correct image url for each tile of google map ……
but dis is wat i want to know dat wat is dat function dat can fetch tile url …..plzzzzzzzzzzzz help me out wid dis
regards varun
October 12th, 2006 at 11:34 am
NASA Maps in your Swing App
Short short version: Not Awesome Awesome! Short version You can now embed some NASA map servers into your own Swing apps using the JXMapViewer component in SwingX-WS. Long version For the Aerith demo we showed at JavaOne we build a…
October 18th, 2006 at 4:05 pm
[…] отке, Ñ€ÐµÑˆÐ°Ñ Ñложные уравнениÑ. Ðо толковые ребÑта Kyle Mulka и Charlie Savage дали толковые объÑÑнениÑ, что Ñделало возмож […]
December 17th, 2006 at 2:24 pm
[…] Warning: For this tutorial I assume you know how to make a function that returns the correct image URL for each tile based on Google’s numbering system. I explain how to use a WMS service to generate tiles for you here. […]
April 24th, 2007 at 1:55 pm
January 4th, 2010 at 4:10 am
hi kyle my aim is to connect Map server and google API for my Indian data.If there is source code available it would be helpful…
thanks in advance
waiting for your reply