In V3 Why we don't have the Layer like V2

217 views
Skip to first unread message

Peter.MapTeam

unread,
Nov 25, 2009, 2:54:27 AM11/25/09
to Google Maps JavaScript API v3
Hi,

- In v2 we using the layer to add the layer from Mapserver to google
map so easy, but now in V3 it don't have the layer so how can we add
the layer from Mapserver to google map like V2

my example :
var tilePanels = new GTileLayer(null, null, null, {
tileUrlTemplate :mapLayerURL,
isPng :true,
opacity :1
});
var layer1=[G_NORMAL_MAP.getTileLayers()[0],tilePanels];
var custommap1 = new GMapType(layer1, G_SATELLITE_MAP.getProjection
(), "Map 1", G_SATELLITE_MAP);
if(myTileLayer){map.removeOverlay(myTileLayer);}
myTileLayer = new GTileLayerOverlay(tilePanels);
map.addOverlay(myTileLayer);

But in V3 we don't have them like V2.

Paul Kulchenko

unread,
Nov 25, 2009, 2:56:35 PM11/25/09
to Google Maps JavaScript API v3
Hi Peter,

v3 API currently doesn't provide this functionality, but there are
several examples on how you can calculate tiles on your own. You can
look at my (http://notebook.kulchenko.com/maps/gridapi) or Berry's
(http://www.provide.net/~bratliff/polycluster/) experiments. It should
be fairly straightforward to replace canvas with an image. In fact,
this example (http://notebook.kulchenko.com/maps/datamark) provides
getTileURL method that you can tweak to point to whatever tile image
you want to load (this particular example is for v2, but the
calculations are the same and the other examples work with v3 API).

Paul (http://notebook.kulchenko.com/maps/)

Peter.MapTeam

unread,
Nov 25, 2009, 10:54:42 PM11/25/09
to Google Maps JavaScript API v3
- Yes thanks you somuch. But now I don't know the way to add the layer
from map server.
- The map server return the images 256x256 so we can get these images,
and in api v2, it's very easy to add the layer by this code below:

function addLayer(){
mapLayerURL = getLayerUrl();
alert(mapLayerURL);
var tilePanels = new GTileLayer(null, null, null, {
tileUrlTemplate :mapLayerURL,
isPng :true,
opacity :1
});
alert(tilePanels);
var layer1=[G_NORMAL_MAP.getTileLayers()[0],tilePanels];
var custommap1 = new GMapType(layer1, G_SATELLITE_MAP.getProjection
(), "Map 1", G_SATELLITE_MAP);
if(myTileLayer){map.removeOverlay(myTileLayer);}
myTileLayer = new GTileLayerOverlay(tilePanels);
map.addOverlay(myTileLayer);
}

===> with the mapLayerURL is the url to get the images from map
server.

http://192.168.72.129/cgi-bin/mapservtile.fcgi?map=/mnt/share/MapIt/bangla.map&layers=lake%20area%20bubble&mode=tile&cutwidth=100&tilemode=gmap&tile=132+90+8

===> and then we new GTileLayerOverlay object and add it to the map
by map.addOverlay(myTileLayer).

But if we using API V3 we can't do it...hix..please help me. thanks
alot.

bratliff

unread,
Nov 27, 2009, 5:04:03 PM11/27/09
to Google Maps JavaScript API v3
On Nov 25, 7:54 am, "Peter.MapTeam" <phucdaid...@gmail.com> wrote:

I have added some "Sparse Tile Layer Overlay" examples:

www.polyarc.us/sparse
www.polyarc.us/rail
www.polyarc.us/road

Esa

unread,
Nov 27, 2009, 5:43:10 PM11/27/09
to Google Maps JavaScript API v3
Nice. I like the idea of background images instead of image objects. I
think that only features you cannot implement with background images,
are the events (onload, onerror).

bratliff

unread,
Nov 27, 2009, 7:40:24 PM11/27/09
to Google Maps JavaScript API v3
> Nice. I like the idea of background images instead of image objects. I
> think that only features you cannot implement with background images,
> are the events (onload, onerror).

Also, background images cannot be scaled but it can be done at the
server.

I have added object properties to simplify specifying mapserver
parameters.

xy.x = tile X offset
xy.y = tile Y offset
xy.X = tile width
xy.Y = tile height
xy.x0 = begin longitude
xy.y0 = begin latitude
xy.x1 = end longitude
xy.y1 = end latitude

Unfortunately, EPSG:4326 does not match the Mercator projection used
by Google, Yahoo & Virtual Earth. Other EPSG Mercator projections are
not universally supported.
Reply all
Reply to author
Forward
0 new messages