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

Options.style (customMapStyle) not applied. #36

Open
Diego251 opened this issue May 24, 2018 · 1 comment
Open

Options.style (customMapStyle) not applied. #36

Diego251 opened this issue May 24, 2018 · 1 comment

Comments

@Diego251
Copy link

Hello, trying to apply a custom style as seen in this example (https://msdn.microsoft.com/en-us/library/mt823636.aspx) using the options object of the leaflet bing layer as follows:

var map = L.map('map').setView([51.505, -0.09], 13)

var myMapStyle = {
    "elements": {
        "water": { "fillColor": "#a1e0ff" },
        "waterPoint": { "iconColor": "#a1e0ff" },
        "transportation": { "strokeColor": "#aa6de0" },
        "road": { "fillColor": "#b892db" },
        "railway": { "strokeColor": "#a495b2" },
        "structure": { "fillColor": "#ffffff" },
        "runway": { "fillColor": "#ff7fed" },
        "area": { "fillColor": "#f39ebd" },
        "political": { "borderStrokeColor": "#fe6850", "borderOutlineColor": "#55ffff" },
        "point": { "iconColor": "#ffffff", "fillColor": "#FF6FA0", "strokeColor": "#DB4680" },
        "transit": { "fillColor": "#AA6DE0" }
    },
    "version": "1.0" 
};

var options = {
    bingMapsKey: BingKey,
    imagerySet: 'RoadOnDemand',
    culture: 'en',
    style: myMapStyle
};

L.tileLayer.bing(options).addTo(map);

However styles do not seem to be applied, the standard Bing style is displayed. Am I missing something?
Thanks!

@Diego251
Copy link
Author

Fix is to complete the metaDataUrl by properly formatting the style and adding it to the URL. This hardcoded example works:

// leaflet-bing-layer.js, line 105:
metaDataUrl = metaDataUrl + "&st=wt|fc:FF0000;lbc:00FF00_rd|fc:0000FF_g|landColor:FFFFFF";

According to Microsoft it can be passed as a POST request if URL is too long.

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

1 participant