ThinkGeo.com    |     Documentation    |     Premium Support

Add Google Layer using Client Java Script

Hi.

I would like to include Google layer using Java Script.

I added following:reference to the Google Map Api:


<script src="<a href=“maps.google.com/maps/api/js?v=3.5&” tabindex=“0”>maps.google.com/maps/api/js?v=3.5&</a>;amp;sensor=false" type=“text/javascript”></script>





Here is the client script:


var googleLayer = new OpenLayers.Layer.Google(‘googleOverlay’,                                                                                                     {type: google.maps.MapTypeId.HYBRID,
                  numZoomLevels: 20});
 
Map1.addLayer(googleLayer);
Map1.setLayerIndex(googleLayer, 0);
 
Map1.redrawLayer(‘googleOverlay’);

Unfortunately the layer is not rendering…



Is something missing here?

Will this approach work?



Thank You.

  



Found resolution:

Map contained _blankWms layer.

After removal google layer started to work.



    var blankLayer = Map1.layers[0];





    Map1.removeLayer(blankLayer);

Great. Please feel free to let us know if any other questions. 
  
 Thanks, 
  
 Troy