Switch to Google Maps Hybrid or Sateline & on custom pages!


#1

I tried to use the app for this; however, it just wouldn't work correctly. Digging through the OpenLayers functions, I found a very quick and easy solution for this.


You'll need to edit the files in views/ that end with _js.php . So with views/Main_js.php look for the IF statements that call the map. After the 5 or so, there is an else statement that actually calls the map. To switch to Google Satelite Hyrbid this is what I did:


Starting at line 61 of Main_js.php:


Code:
else
{
map_layer = new OpenLayers.Layer.Google("Google Hybrid", {
[b]type: G_HYBRID_MAP[/b],
sphericalMercator: true,
maxExtent: new OpenLayers.Bounds(-20037508.34,-20037508.34,20037508.34,20037508.34)
});

All you need to do is change the TYPE to G_HYBRID_MAP. You can rename the tag in the quote if you want, but it is not necessary.


You can switch this on different pages, so the Reports View can display a streets map, or perhaps just a satelite view.


The downside is that it negates your backend setting, so if you want to change it later you have to go back into the code, but it is one line of code.


Also, if you download the new OpenLayers version you can use the V3 api, they offer the tag you need to put into your header somewhere in their wiki.


Hope this helps, let me know if you have any questions and I'll try to help!


Cheers,


AS



#2

an alternative is to adding the hybrid google map as an option, this way the settings in the admin panel will still be correct, If you put the custom code in front of all the IF statements, the hybrid map will be the default one and configured map in the settings could be activated by the user.


Code:
(...) else
{
map_layer = new OpenLayers.Layer.Google("google", {
sphericalMercator: true,
maxExtent: new OpenLayers.Bounds(-20037508.34,-20037508.34,20037508.34,20037508.34)
});
}
map.addLayer(map_layer);

// custom code
map_layer_GoogHyb = new OpenLayers.Layer.Google("Google Satelite", {
type: G_HYBRID_MAP,
sphericalMercator: true,
maxExtent: new OpenLayers.Bounds(-20037508.34,-20037508.34,20037508.34,20037508.34)
});

map.addLayer(map_layer_GoogHyb); //se agrega a la lista
//END of custom code


Andres maybe we are trying to figure out similar things, contact me if you want to share tips and help each other out, you can email me at comunicaciones@votojoven.com