Posted by nottaken on May 12, 2011 at 9:40pm
4 followers
Jump to:
| Project: | OpenLayers |
| Version: | 6.x-2.0-alpha10 |
| Component: | Code |
| Category: | support request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | postponed (maintainer needs more info) |
Issue Summary
I have a custom google layer (currently used with GM v3 api) that I'd like to use as a OpenLayers layer. Before I dive into hacking around on a module to add this layer type. Is it possible to add a layer based on a url?
Here is a snippet of my javascript I have been using with google maps v3.
// Google Roads layer
getTileUrl: function(ll, z) {
var X = ll.x % (1 << z);
return "http://mt0.google.com/vt/v=apt.116&hl=en-US&x="
+ X + "&y=" + ll.y + "&z=" + z + "&src=apiv3&s=G&lyrs=r&apistyle=s.t:33|p.v:off&apistyle=s.t:49|s.e:l|p.v:on|p.l:50|p.s:24,s.t:5|p.v:off,s.t:6|p.v:off,s.t:1|p.v:off,s.t:5|p.v:off,s.t:2|p.v:off"
},
tileSize: new google.maps.Size(256, 256),
isPng: false,
maxZoom: 18,
name: "Roads",
alt: "Custom Roads"
},Thanks,
Brian
Comments
#1
Hi @nottaken. I don't have much experience with this. This module uses the built-in Google maps stuff, so it's pretty simple. It would be cool to know what you find out.
#2
zzolo,I added a sandbox project to do this. My first attempt at a D.O project - happy to hear feedback, and general comments about it.
Google Map Styled
http://drupal.org/sandbox/youngblood/1170046
#3
Hi @nottaken. This pretty cool. The one thing I am a little worried about is that this accesses Google Tiles directly, which, from what I understand, is against Google's terms of use. One can only access them through their API. I would be happy to be wrong about this, but this is my current understanding.
#4
zzolo, ah that may be true, although as you said hopefully this is not the case. I know others are doing this, but have not seen anything with the openlayers module. Various examples are already in the wild, but implementing the v3 api to do this shouldn't be a big deal, and would make it easier to implement the styles by using the json string given in the wizard.
The javascript code was based on examples here:
http://docs.openlayers.org/library/spherical_mercator.html
#5
I'm looking into the documentation for OpenLayers.Layer.Google to see if you can add a google map as a overlay. As far as I can tell it doesn't have a isBaseLayer property. Does anyone know if any of the Google map layers are usable as a overlay, or are they just base maps?
#6
subscribing
#7
I've played around a little with the xyz layer type, and it seems to do the same thing. The base url just needs to be increase per issue http://drupal.org/node/1187596.
#8
FWIW:
-- Google Maps/Google Earth APIs Terms of Service
#9
Thanks @jeffschuler. That's what I figured.
So, the OL library actually sits on top of the Google Maps API, when displaying Google layers. The Google Maps API object is referenceable, so this means that there has to be some way to hack this together, but utilizing the Google Maps API within the OL context.
#10
I haven't really grokked the example provided in the original post, but If what we're trying to do here is use a Google Styled Maps-created base layer, @nod_ has a working example of a custom module that provides an OL layer with Google's custom styling JSON.
#11
@jeffschuler, this was my overall goal - create a layer, and take the json string from the google custom styling wizard to display the overlay. Ideally, it would be useful to use this layer as a overlay, and not a base layer.
I'd be interested in seeing the work @nod_ has done here.
Thanks,
brian