简体   繁体   中英

Google Maps v3 with Openlayers - First Zoom Level

I use Google Maps v3 in my application and I noticed a strange behavior, When I refresh the web page, the map zoomed out to display the whole map then get back to the zoom level I specify in my code. This happen fast but every time I refresh the page. How can I fix it?

We once had this problem in our app but I just checked and it isn't happening any more. I can't remember what I did to fix it but here are some things to consider or try:

  1. Set the maxExtent of your map to be the same as your base (Google) layer.
  2. When we set up our google layer we set spherical mercator to true.
  3. Check that your map's projection is "EPSG:900913", but this may have no effect.

     // get max extent from base layer and set in map map.maxExtent = map.getMaxExtent(); // create a Google layer layer.params.sphericalMercator = true; layer.params.maxExtent = new OpenLayers.Bounds(-20037508.34,-20037508.34,20037508.34,20037508.34); var googleLayer = new OpenLayers.Layer.GoogleWfdss(layer.id, layer.params); 

These might seem obvious but I thought I'd give you some other directions for debugging if you hadn't considered them.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM