2

How do we add the weather overlay option to a Google map, just like on Google my maps? I've searched for it, but i can't find the answer.

Do i have to call a weather web service?

Kara
  • 6,115
  • 16
  • 50
  • 57
j.b
  • 151
  • 1
  • 7
  • 17
  • 1
    WeatherLayer is no longer available http://googlegeodevelopers.blogspot.com.au/2014/06/sunsetting-javascript-api-weather-panoramio.html – rainy Jan 13 '16 at 00:38
  • Google seems to recommend using Open Weather Map, as of 2015. https://github.com/google/maps-for-work-samples/blob/master/samples/maps/OpenWeatherMapLayer/OpenWeatherMapLayer.pdf – mstrom Oct 23 '18 at 16:00

2 Answers2

3

You can display the WeatherLayerdev-guide on your map by taking two steps:

First, load the WeatherLayer library by adding the libraries parameter to the URL you use to load the map:

<script type="text/javascript"
  src="http://maps.googleapis.com/maps/api/js?libraries=weather&sensor=false">
</script>

Then, you must create an instance of the google.maps.weather.WeatherLayerapi-doc class, passing any options in a WeatherLayerOptionsapi-doc object, and attach the WeatherLayer to the map:

var weatherLayer = new google.maps.weather.WeatherLayer({
  temperatureUnits: google.maps.weather.TemperatureUnit.FAHRENHEIT
});
weatherLayer.setMap(map);

In addition to the WeatherLayer, there is also a separate google.maps.weather.CloudLayerapi-doc class that you may create in a similar way:

var cloudLayer = new google.maps.weather.CloudLayer();
cloudLayer.setMap(map);

There is no separate library that you must load to use the CloudLayer; adding the libraries=weather parameter to the URL that loads the map makes both the WeatherLayer and the CloudLayer available on your map. There as a Google Maps JavaScript API v3 Example: Weather Layer, that shows the usage of both layers.

Sean Mickey
  • 7,618
  • 2
  • 32
  • 58
2

I have got same trouble when I tried to use Google map apiv3 with weather layer. But luckily, I found this site http://code.google.com/p/gmaps-samples-v3/ that provides all Google map api v3 samples and they are worked. Hope this help.

Cuong Vo