Try changing your overlay declaration from
var overlay;
to
var overlay = new google.maps.OverlayView();
overlay.setMap(map);
overlay.draw = function () {
if (!this.ready) {
this.ready = true;
google.maps.event.trigger(this, 'ready');
}
};
On Nov 21, 7:27 am, so0ly <[email protected]> wrote:
> Hi,
>
> I'm trying to do an overlay on Google Maps. I have generated tiles of
> my image using maptiler, but the example generated by maptiler is in
> v2 and i want to use v3. The example generated by maptiler is also
> very complex and does some unnecessary opacity stuff. Now v3 of GM has
> changed a lot since v2 and i have some problems to generate the LatLng
> of a certain point on the screen. getProjection() keeps being
> undefined, whatever i do, any idea how to get the projection?
>
> <script>
> var mapBounds = new google.maps.LatLngBounds();
> var mapMinZoom = 8;
> var mapMaxZoom = 14;
> var overlay;
>
> var maptiler = new google.maps.ImageMapType({
> getTileUrl: function(coord, zoom) {
> if ((zoom < mapMinZoom) || (zoom > mapMaxZoom)) {
> return "none.png";
> }
> var ymax = 1 << zoom;
> var y = ymax - coord.y -1;
> var tileBounds = new google.maps.LatLngBounds(
> overlay.getProjection().fromDivPixelToLatLng( new
> google.maps.Point( (coord.x)*256, (coord.y+1)*256 ) , zoom ),
> overlay.getProjection().fromDivPixelToLatLng( new
> google.maps.Point( (coord.x+1)*256, (coord.y)*256 ) , zoom )
> );
> if (mapBounds.intersects(tileBounds)) {
> return "" + zoom + "/" + coord.x + "/" + (Math.pow(2,zoom)-
> coord.y-1) + ".png";
> } else {
> return "none.png";
> }
> },
> tileSize: new google.maps.Size(256, 256),
> isPng: true
> });
>
> var map;
> function initialize() {
> map = new
> google.maps.Map(document.getElementById("map_canvas"));
> map.setZoom(11);
> map.setMapTypeId('satellite');
> mapBounds.extend(new google.maps.LatLng(50.9388615939,
> 3.80480816501));
> mapBounds.extend(new google.maps.LatLng(51.4402541425,
> 4.73612507791));
> map.fitBounds(mapBounds);
>
> overlay = new google.maps.OverlayView();
> overlay.draw = function() {};
> overlay.setMap(map);
>
> map.overlayMapTypes.insertAt(0, maptiler);
> }
> </script>
>
> the overlay part is a hack i found on the internet which supposed to
> get you to the projection. unfortunately it didn't work. Any idea's
> how to fix this? in V2 you could do something like this:
>
> var mercator = new GMercatorProjection()
> mercator.fromPixelToLatLng( new GPoint( (tile.x)*256, (tile.y
> +1)*256 ) , zoom )
>
> But this isn't possible anymore in v3.
>
> Anyone that can help?
>
> The example generated by maptiler can be found here:
>
> http://gmapsexample.staging1.kunstmaan.be/googlemapsv2.html
>
> This is a simple example in v3 which works:
>
> http://gmapsexample.staging1.kunstmaan.be/googlemapsv3_simple.html
>
> but i want everything except the map to be a specific color, so this
> is the example i'm trying to get working:
>
> http://gmapsexample.staging1.kunstmaan.be/googlemapsv3.html
>
> thanks,
>
> Daan
--
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 [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-maps-js-api-v3?hl=en.