<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<title></title>
<link href="http://code.google.com/apis/maps/documentation/javascript/examples/default.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=false"></script>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
<script type="text/javascript">
function render() {
var rows = $("#data").val().split("\n");
var latlng = new google.maps.LatLng(0,0);
var cnt = 1;
var options = {
zoom: 4,
center: latlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById("map_canvas"), options);
$.each(rows, function() {
var d = this.split(",");
latlng = new google.maps.LatLng(d[1],d[0]);
if(cnt == 1) {
map.setCenter(latlng);
}
/* V3では map.addOverlay(marker) は使わないらしい */
var marker = new google.maps.Marker({
position: latlng,
map: map,
});
cnt++;
});
}
</script>
</head>
<body>
<textarea id="data" cols="80" rows="10">
141.3478394,43.0583725,61.24,Thu Jun 09 18:12:29 2011
142.3478394,43.0583725,61.24,Thu Jun 09 18:12:29 2011
143.3478394,43.0583725,61.24,Thu Jun 09 18:12:29 2011
</textarea>
<input type="button" value="submit" onclick="render();" />
<div id="map_canvas"></div>
</body>
</html>
More than 5 years have passed since last update.
google maps api V3で複数のマーカーを描画する
Last updated at Posted at 2012-12-26
Register as a new user and use Qiita more conveniently
- You get articles that match your needs
- You can efficiently read back useful information
- You can use dark theme
List of users who liked
23