0

I have a WMS server (using MapServer and Apache on windows). i read this document about Mapserver's Tile Mode and use that's example to overlay my map on Google maps.but not work.

my code:

function load() {
  if (GBrowserIsCompatible()) {
    var urlTemplate = 'http://79.175.166.195:1280/cgi-bin/mapserv.exe?';
        urlTemplate += 'map=C:\\ms4w\\apps\\Rasht\\RashtMap.map&';
        urlTemplate += 'layers=base street&';
        urlTemplate += 'mode=tile&';
        urlTemplate += 'tilemode=gmap&';
        urlTemplate += 'tile={X}+{Y}+{Z}';
    var myLayer = new GTileLayer(null,0,18,{
                                 tileUrlTemplate:urlTemplate,
                                 isPng:true,
                                 opacity:1.0 });
    var map = new GMap2(document.getElementById("map"));
    map.addControl(new GLargeMapControl());
    map.addControl(new GMapTypeControl());
    map.setCenter(new GLatLng(37.282340, 49.588540), 15);
    map.addOverlay(new GTileLayerOverlay(myLayer));
  }
}

what is wrong?

2

It will never work. You are using code for the deprecated Google Maps API v2. Trying what's happened with the sample, I get a message like below

Control is no longer supported in the Google Maps Javascript API v2. Please visit developers.google.com/maps/documentation/javascript/v2/v2tov3 to migrate your application to v3.

I didn't dive into the code but there are working examples using WMS everywhere. MapServer can deliver WMS although the code you mentioned relies on the old way to serve MapServer maps (CGI-mode).

Using a search engine, I found various demos like this one, this other, this third demo or this last one to get hints to make a working example.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.