bodyにscriptを追加。
var script = document.createElement('script'); script.src = 'http://example.com/hoge.js'; document.body.appendChild(script);
window.はdomを収める
mapTypeId: ‘terrain’ 地形情報を使った地図
ROADMAP 道路や建物
SATELITE 衛星写真
HyBRID ROADMAPとSATELITE
TERRAIN 地形情報
デフォルトはROADMAP
<!DOCTYPE html> <html> <head> <title>Simple Map</title> <meta name="viewport" content="initial-scale=1.0"> <meta charset="utf-8"> <style> #map { height: 50%; margin-top: 10px; } html, body { height: 100%; margin: 10px; padding: 0; } </style> </head> <body> <div id="map"></div> <script> var map; function initMap(){ map = new google.maps.Map(document.getElementById('map'),{ zoom: 2, center: new google.maps.LatLng(2.8, -187.3), mapTypeId: 'terrain' }); var script = document.createElement('script'); script.src = 'https://developers.google.com/maps/documentation/javascript/examples/json/earthquake_GeoJSONP.js'; document.getElementsByTagName('head')[0].appendChild(script); } window.eqfeed_callback = function(results) { for (var i = 0; i < results.features.length; i++) { var coords = results.features[i].geometry.coordinates; var latLng = new google.maps.LatLng(coords[1],coords[0]); var marker = new google.maps.Marker({ position: latLng, map: map }); } } </script> <script async defer src = "https:maps.googleapis.com/maps/api/js?key=notwatchk&callback=initMap"> </script> </body> </html>