<?php

$filename = 
"tiles/".intval($_GET['z'])."/".intval($_GET['x'])."/".intval($_GET['y']).".png";

header("Content-Type: image/png");
header("Cache-Control: max-age=84600");

if (file_exists($filename)) {
  header("Content-Length: ".filesize($filename));
  readfile($filename);
} else {
  header("Content-Length: 95");
  readfile("transparent1x1.png");
}



Change to suit your needs.


On Fri, Jul 29, 2011 at 4:52 PM, Jason <jason.wool...@gmail.com> wrote:
> Does anyone know of a page or an example where this is done with PHP?
> Makes sense but I haven't done much PHP.
>
> Thanks
>
> On Jul 28, 11:40 pm, Martin™ <warwo...@gmail.com> wrote:
>> Why not make all tile requests to a PHP script?
>>
>> The script can check if the requested tile exists.
>> If the tile exists then the script can return it to the map, otherwise
>> it can return a blank transparent tile.
>>
>> http://php.net/manual/en/function.file-exists.php
>>
>> http://www.php.net/manual/en/function.file-get-contents.php
>>
>> A transparent 1 x 1 pixel PNG image can be used where there is no tile
>> and that could be as small as 95 bytes:
>>
>> http://code.martinpearman.co.uk/deleteme/transparent_1x1.png
>>
>> Martin.
>>
>> On Jul 28, 1:28 pm, Jason <jason.wool...@gmail.com> wrote:
>>
>> > I'd really like to know a fix for this too. It's been a problem for me
>> > for quite a while and I can't easily get write permission
>> > to .htaccess.
>>
>> > On Jul 27, 1:46 pm, Kesuke <nick_dai...@hotmail.com> wrote:
>>
>> > > I am using custom tile overlays on a map. To fetch the tiles I use the
>> > > generic method:
>>
>> > >  function createImageMapType(id, opacityvalue) {
>> > >     return new google.maps.ImageMapType({
>> > >       getTileUrl: function(coord, zoom) {
>> > >         return "/tiles/" + id + "/"+ zoom + "_" + coord.x + "_" +
>> > > coord.y + ".png";
>> > >       },
>> > >       tileSize: new google.maps.Size(256, 256),
>> > >       isPng: true,
>> > >       opacity: opacityvalue
>> > >     });
>> > >   }
>>
>> > > Here is the problem: My map uses lots of transparent PNG tiles, and
>> > > infact some tiles are completely transparent. So rather than have
>> > > thousands of 3kb empty PNG files, I just don’t have those tiles.
>>
>> > > This works but it technically generates a lot of 404 bad request
>> > > errors. An average user visit can make as many as 300 bad requests.
>> > > This really hurts page load time and also looks bad for search
>> > > engines.
>>
>> > > So, does anyone have an idea how I could only fetch tiles that
>> > > actually exist?
>>
>> > > One other idea I have had is could I setup an .htaccess rule that
>> > > redirects to a universal empty PNG file for any tile that can’t be
>> > > found (so it doesn’t return a bad request).
>>
>> > > I don’t want to generate empty tiles as I have over 130 custom tile
>> > > overlays for zoom levels 1 through 5. Just at zoom level 5 that would
>> > > be something like 140,000 files and my server is limited.
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Google Maps JavaScript API v3" group.
> To post to this group, send email to google-maps-js-api-v3@googlegroups.com.
> To unsubscribe from this group, send email to 
> google-maps-js-api-v3+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/google-maps-js-api-v3?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Maps JavaScript API v3" group.
To post to this group, send email to google-maps-js-api-v3@googlegroups.com.
To unsubscribe from this group, send email to 
google-maps-js-api-v3+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-maps-js-api-v3?hl=en.

Reply via email to