Skip to content

Instantly share code, notes, and snippets.

@kzfm
Created May 10, 2012 21:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kzfm/2656152 to your computer and use it in GitHub Desktop.
Save kzfm/2656152 to your computer and use it in GitHub Desktop.
googlemapsでクリックするとtwittericonでマーカーが設置されるサンプル
<!DOCTYPE html><html><head><script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script><link rel="stylesheet" href="style.css"><script>var map;
function initialize() {
var myLatlng = new google.maps.LatLng(35.360556,138.727778);
var myOptions = {
zoom: 11,
center: myLatlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
google.maps.event.addListener(map, 'click', function(event) {
placeMarker(event.latLng);
});
}
function placeMarker(location) {
var contentString = 'hello world';
var infowindow = new google.maps.InfoWindow({
content: contentString
});
var marker = new google.maps.Marker({
position: location,
map: map,
icon: new google.maps.MarkerImage(
'https://si0.twimg.com/profile_images/1101313417/40dea9e7-aef7-4320-8d71-6d1108ffa98c.png',
new google.maps.Size(32, 32),
new google.maps.Point(0,0),
new google.maps.Point(0, 32),
new google.maps.Size(32, 32)
)
});
google.maps.event.addListener(marker, 'click', function() {
infowindow.open(map,marker);
});
map.setCenter(location);
setTimeout(function () {marker.setMap(null);;}, 10000);
}
google.maps.event.addDomListener(window, 'load', initialize);
</script></head><body><div id="map_canvas"></div></body></html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment