#1 Mon 30 May 2016 16:06
- asma_kadjoudj
- Juste Inscrit !
- Date d'inscription: 22 May 2016
- Messages: 8
kmllayer
Bonjour. Lorsque vous exécutez ce programme mais map affiche pas???????
http://jsfiddle.net/nz78nk80/2/?utm_sou … n=nz78nk80
Code:
<!DOCTYPE html> <html> <head> <title> asma </title> <style> html, body, #map-canvas { height: 100%; width: 100%; margin: 0px; padding: 0px } </style> </head> <body> <script> var map; var watershedLayer = new google.maps.KmlLayer({ url: 'http://mvihes.bc.ca/mapping/watersheds.kmz' }); var ere1949Layer = new google.maps.KmlLayer({ url: 'http://mvihes.bc.ca/mapping/ere1949.kmz' }); function initialize() { var parksville = new google.maps.LatLng(49.316786, -124.308768); var mapOptions = { zoom: 9, center: parksville }; map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions); check(); } function check() { if (document.getElementById('watersheds').checked) { if (!watershedLayer.getMap()) watershedLayer.setMap(map); } else { watershedLayer.setMap(null); } if (document.getElementById('ere1949').checked) { if (!ere1949Layer.getMap()) ere1949Layer.setMap(map); } else { ere1949Layer.setMap(null); } } google.maps.event.addDomListener(window, 'load', initialize); </script> <label>watersheds</label><input type="checkbox" id="watersheds" onclick="check();" onchange="check();"/><label>ere1949</label><input type="checkbox" id="ere1949" onclick=" check();" onchange="check();" /> <div id="map-canvas" style="border: 2px solid #3872ac;"></div> </body> </html>
Hors ligne
#2 Mon 30 May 2016 16:11
Re: kmllayer
Bonjour,
Vous ne faites pas appel à la librairie Google Maps.
Vous devez quelque part dans votre code inclure un appel JS vers l'API.
<script src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&callback=initMap"
async defer></script>
Cordialement,
Hors ligne