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

Colored Lines Do Not Work on Styled Google Maps #4

Closed
schnuerle opened this issue Mar 13, 2012 · 3 comments
Closed

Colored Lines Do Not Work on Styled Google Maps #4

schnuerle opened this issue Mar 13, 2012 · 3 comments

Comments

@schnuerle
Copy link

If you use Google's styled maps option (http://code.google.com/apis/maps/documentation/javascript/styling.html) and try to assign a leg color (legColors.usual[mti.ROADMAP] = '#444';), the colors don't work.

When you specify a style, you override a current Google style, like ROADMAP:

var mapOptions = {
mapTypeControlOptions: { mapTypeIds: [google.maps.MapTypeId.ROADMAP, 'custom_style_name'] }
};

So there should be some way to access this new style, but ROADMAP is not the way. Here is a test link. Click the orange marker to the right of the center marker.

http://www.yourmapper.com/mapV3.php?id=174&num=25&lat=38.23469126&lon=-85.7198380

The spiderfied lines should be blue with an orange highlight (as you can see in the Terrain view), but they are the default black with no highlight.

@jawj
Copy link
Owner

jawj commented Mar 13, 2012

I think you've slightly misunderstood the map styling documentation. Your example code above doesn't override the ROADMAP style -- it just asks for a map control to toggle between ROADMAP and a custom style.

This is how you add custom styles to a map, and how you then change the line colour of the spider legs:

var gm = google.maps;

var map = new gm.Map(document.getElementById('map_canvas'), {
  mapTypeId: gm.MapTypeId.SATELLITE, center: new gm.LatLng(50, 0), zoom: 6
});

var sepiaStyles = [ { stylers: [ { gamma: 0.5 }, { saturation: -65 }, { hue: "#ffaa00" } ] },
    { elementType: "labels", stylers: [ { visibility: "off" } ] } ];

var sepiaMapType = new gm.StyledMapType(sepiaStyles, {name: "Sepia"});
map.mapTypes.set('sepia', sepiaMapType);
map.setMapTypeId('sepia');

var oms = new OverlappingMarkerSpiderfier(map);
oms.legColors.usual.sepia = '#f00';
oms.legColors.highlighted.sepia = '#ff0';

@jawj jawj closed this as completed Mar 13, 2012
@schnuerle
Copy link
Author

Thanks a lot for the quick reply. That did the trick. I did misunderstand the Google implementation, and I didn't try to call the custom style type correctly with oms.

@jawj
Copy link
Owner

jawj commented Mar 13, 2012

No problem. Glad you got it sorted.

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