Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

google map, leaflet: Can not export google map to image #135

Open
huyhoangtb opened this issue May 19, 2020 · 1 comment
Open

google map, leaflet: Can not export google map to image #135

huyhoangtb opened this issue May 19, 2020 · 1 comment

Comments

@huyhoangtb
Copy link

I use leaflet-image to export image but I can not see the map on the result.
But I can see polygons, titles, and another layer.

image

web app:
image

==> result:

image

@Black-Dragon-Spirit
Copy link

It's because the maxnative zoom for google maps is 19.

A quick and dirty solution would be:
` if (zoom > 19) {
var zf = Math.pow(2,zoom);
var mf = Math.pow(2,19);
var _xmin = bounds.min.divideBy(tileSize).divideBy(zf).multiplyBy(mf);
var _xmax = bounds.max.divideBy(tileSize).divideBy(zf).multiplyBy(mf);

		var bounds2 = L.bounds(_xmin,_xmax);
		var tileBounds = L.bounds(_xmin._floor(),_xmax._floor()),
        tiles = [],
        j, i,
        tileQueue = new queue(1);
	} else {
		var tileBounds = L.bounds(
        bounds.min.divideBy(tileSize)._floor(),
        bounds.max.divideBy(tileSize)._floor()),
        tiles = [],
        j, i,
        tileQueue = new queue(1);
	}`

And change the tileQueue.defer();

if (zoom > 19) { var tilePos2 = originalTilePoint.scaleBy(new L.Point(tileSize, tileSize)); tilePos2 = tilePos2.divideBy(Math.pow(2,19)).multiplyBy(Math.pow(2,zoom)); tilePos2 = tilePos2.subtract(bounds.min); tileQueue.defer(loadTile, url, tilePos2, tileSize * ((zoom - 19) * 2)); } else { tileQueue.defer(loadTile, url, tilePos, tileSize); }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants