Created
May 10, 2012 21:55
-
-
Save kzfm/2656152 to your computer and use it in GitHub Desktop.
googlemapsでクリックするとtwittericonでマーカーが設置されるサンプル
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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