teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

2

code囲んでみました

2016/08/31 02:37

投稿

kinue
kinue

スコア8

title CHANGED
File without changes
body CHANGED
@@ -3,7 +3,7 @@
3
3
  マーカーが表示されたりされなかったりします。
4
4
 
5
5
  apiキーは取得し、下記を書き換えてもだめでした。
6
-
6
+ ```ここに言語を入力
7
7
  <meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
8
8
  <script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=false&hl=ja"></script>
9
9
  <script type="text/javascript">
@@ -71,4 +71,5 @@
71
71
  </head>
72
72
  <body onload="initialize()">
73
73
  <div id="map_canvas" style="width:940px; height:500px"></div>
74
- </body>
74
+ </body>
75
+ ```

1

ソース入れてみました

2016/08/31 02:37

投稿

kinue
kinue

スコア8

title CHANGED
File without changes
body CHANGED
@@ -1,3 +1,74 @@
1
1
  googlemapマイマップからkmlを抽出しオーバーレイさせています。
2
2
  ですが、動作がとても不安定で
3
- マーカーが表示されたりされなかったりします。
3
+ マーカーが表示されたりされなかったりします。
4
+
5
+ apiキーは取得し、下記を書き換えてもだめでした。
6
+
7
+ <meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
8
+ <script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=false&hl=ja"></script>
9
+ <script type="text/javascript">
10
+ function initialize() {
11
+ var initPos = new google.maps.LatLng(35.8788443, 137.0211659);
12
+ var myOptions = {
13
+ noClear : true,
14
+ center : initPos,
15
+ zoom : 6,
16
+ mapTypeId : google.maps.MapTypeId.ROADMAP
17
+ };
18
+ var mapCanvas = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
19
+
20
+ var ctime = (new Date()).getTime();
21
+ var kmlUrl = "/gmp/810o.kml?t="+ctime;
22
+ var ctaLayer = new google.maps.KmlLayer(kmlUrl, {
23
+
24
+ suppressInfoWindows : true, //←kmlレイヤーで情報ウインドウを開かないようにするこれ
25
+ map: map_canvas,
26
+ preserveViewport: true
27
+
28
+ });
29
+
30
+ ctaLayer.setMap(mapCanvas);
31
+
32
+
33
+ var infoWnd = new google.maps.InfoWindow();
34
+
35
+
36
+ google.maps.event.addListener(ctaLayer, "click" ,function(kmlMouseEvent) {
37
+
38
+
39
+
40
+ infoWnd.setContent(kmlMouseEvent.featureData.infoWindowHtml);
41
+ infoWnd.setPosition(kmlMouseEvent.latLng);
42
+
43
+
44
+ infoWnd.setOptions({
45
+ maxWidth: 400,
46
+
47
+ });
48
+
49
+ infoWnd.open(mapCanvas);
50
+ });
51
+
52
+ }
53
+
54
+
55
+ function createMarker(latlng,html,map,category,name)
56
+ {
57
+
58
+
59
+
60
+ google.maps.event.addListener(marker, 'click', function()
61
+ {
62
+ infoWindow.setContent(html);
63
+ infoWindow.open(map,marker);
64
+
65
+ });
66
+
67
+
68
+ }
69
+
70
+ </script>
71
+ </head>
72
+ <body onload="initialize()">
73
+ <div id="map_canvas" style="width:940px; height:500px"></div>
74
+ </body>