开发者

How do I add an overlay to my OpenStreetMap

I currently use a google map and create tiles for it by using a PHP script to generate the required PNG images

 var myTileLayer = new GTileLayerOverlay(
                                new GTileLayer(null, null, null, {
                                    //tileUrlTemplate: 'Overlays/Overlay_{Z}_{X}_{Y}.png',
                                    tileUrlTemplate: 'gentile.php?Zoom={Z}&TileX={X}&TileY={Y}',
                                    isPng:true,
                                    opacity:1.0
                                })
                            );

                                map.addOverlay(myTileLayer);

I now wish to use OpenStreetMap and according to this source: http://wiki.openstreetmap.org/wiki/OpenLayers_Simple_Example

I need to use this code to acheive that, however it seems to want me to use pre开发者_开发知识库made tiles when I want to gen them on the fly

 var newLayer = new OpenLayers.Layer.OSM("New Layer", "URL_TO_TILES/${z}/${x}/${y}.png", {numZoomLevels: 19});
 map.addLayer(newLayer);

Really I need to use gentile.php?Zoom={Z}&TileX={X}&TileY={Y}


I think, you whant to use OpenLayers to show your own Overlay on an OSM(or what ever)-map?

And you hav to use and your tiles lays at an URL like "gentile.php?Zoom={Z}&TileX={X}&TileY={Y}"

So try to add the layer with:

var newLayer = new OpenLayers.Layer.OSM("New Layer", "gentile.php?Zoom=${Z}&TileX=${X}&TileY=${Y}", {numZoomLevels: 19});

i've used that an year ago...

if that doesn't work write an htaccess - mod_rewrite

eg something like that:

RewriteRule ^(.*)/(.*)/(.*).png$ gentile.php?Zoom=$1&TileX=$2&TileY=$3 [NC]
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜