Author Topic: Opacity of base maps  (Read 1590 times)

0 Members and 1 Guest are viewing this topic.

Offline mapcat

  • TM Collaborator
  • Hero Member
  • *****
  • Posts: 905
  • Last Login:Today at 10:04:26 pm
Opacity of base maps
« on: February 29, 2016, 07:59:12 pm »

How possible would it be to make the opacity of the base maps user-controlled? For example, the US Census Bureau's TIGERWeb features an opacity slider on its maps.


https://tigerweb.geo.census.gov/tigerweb/


(expand any category in the layers menu to see it)
Clinched:

Offline Jim

  • TM Collaborator
  • Hero Member
  • *****
  • Posts: 1559
  • Last Login:Today at 09:37:41 pm
Re: Opacity of base maps
« Reply #1 on: February 29, 2016, 08:11:45 pm »
Do you mean the background map tiles?  If so, only if Google's API has that level of control, I think.


How possible would it be to make the opacity of the base maps user-controlled? For example, the US Census Bureau's TIGERWeb features an opacity slider on its maps.


https://tigerweb.geo.census.gov/tigerweb/


(expand any category in the layers menu to see it)

Offline mapcat

  • TM Collaborator
  • Hero Member
  • *****
  • Posts: 905
  • Last Login:Today at 10:04:26 pm
Re: Opacity of base maps
« Reply #2 on: February 29, 2016, 08:19:49 pm »
Do you mean the background map tiles?  If so, only if Google's API has that level of control, I think.
That's right. Thanks.
Clinched:

Offline theFXexpert

  • TM Collaborator
  • Jr. Member
  • *****
  • Posts: 88
  • Gender: Male
  • Last Login:February 22, 2017, 01:35:32 pm
Re: Opacity of base maps
« Reply #3 on: March 02, 2016, 11:01:26 am »
Somewhat relevant: I submitted a pull request that implements a blank map layer as described in this issue.

https://github.com/TravelMapping/Web/pull/46

After playing around with Chrome's JS console, google does have functions for setting opacity for defined map types: map.mapTypes.Mapnik.setOpacity(0.5) for example.
I have only been able to get it to work with the MQOpenMap, MQOpenSat, and Mapnik layers. For whatever reason this doesn't work on google's built-in layers.

Offline Jim

  • TM Collaborator
  • Hero Member
  • *****
  • Posts: 1559
  • Last Login:Today at 09:37:41 pm
Re: Opacity of base maps
« Reply #4 on: March 03, 2016, 08:39:23 pm »
Somewhat relevant: I submitted a pull request that implements a blank map layer as described in this issue.

https://github.com/TravelMapping/Web/pull/46

Thanks, I hope to get this and the other items that have been submitted tested out and (if all seems OK) live on the site in the next few days.

Offline yakra

  • TM Collaborator
  • Hero Member
  • *****
  • Posts: 2364
  • Last Login:Today at 06:24:13 pm
Re: Opacity of base maps
« Reply #5 on: March 04, 2016, 12:43:02 am »
Sorry, this is a bit OT, but...
theFXexpert, IIRC you originally added the OpenMQ and Mapnik layers to the HB. Many thanks for that! At the time, I took a look at the CHM HB & Waypoint Editor, and tried to figure out how one might add in the code for BingMap and BingSat layers, but came up empty-handed. Do you have any insight here?

Offline theFXexpert

  • TM Collaborator
  • Jr. Member
  • *****
  • Posts: 88
  • Gender: Male
  • Last Login:February 22, 2017, 01:35:32 pm
Re: Opacity of base maps
« Reply #6 on: March 04, 2016, 12:32:04 pm »
Sorry, this is a bit OT, but...
theFXexpert, IIRC you originally added the OpenMQ and Mapnik layers to the HB. Many thanks for that! At the time, I took a look at the CHM HB & Waypoint Editor, and tried to figure out how one might add in the code for BingMap and BingSat layers, but came up empty-handed. Do you have any insight here?
The MQOpen/Mapnik layers were actually very easy to add since the code for getting the tiles on CHM is visible in Chrome's Developer tools in maptypes.js. If I remember correctly, Jim already copied some of the maptypes.js code over into TM's JavaScript files with many of the lines commented out.

The Bing maps are a whole other deal though. The code for returning Bing tiles in CHM is returned from http://cmap.m-plex.com/hb/ymaptile.php along with a number of query string parameters. The code for that PHP file is not visible to me therefore, I don't know how to port the code over here.

After some googling, Bing uses a significantly different URL system for delivering tiles: http://stackoverflow.com/questions/3109595/integrating-bing-maps-tiles-into-google-maps-api
While the code given in one of the answers technically works, in order to dynamically generate valid tile URLs, a Bing Maps API Key is required: http://stackoverflow.com/questions/6278362/bing-maps-direct-access-to-tiles-and-api-key