Last active
May 5, 2017 04:05
-
-
Save enqtran/b3f6efae03090198b09d3b7e89a3a75a to your computer and use it in GitHub Desktop.
This file contains hidden or 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
<div id="map_canvas" style="width:100%;height:500px;"></div> | |
<script> | |
function initMap() { | |
api = 'https://maps.googleapis.com/maps/api/geocode/json?address={address}®ion=jp&key={key}'; | |
jQuery.getJSON(api, function(r){ | |
var abc = $.parseJSON(JSON.stringify(r)); | |
var lat = abc['results'][0].geometry.location.lat; | |
var lng = abc['results'][0].geometry.location.lng; | |
var uluru = {lat: lat, lng: lng }; | |
console.log(uluru); | |
var map = new google.maps.Map(document.getElementById('map_canvas'), { | |
zoom: 16, | |
center: uluru | |
}); | |
var contentString = '{html content}'; | |
var infowindow = new google.maps.InfoWindow({ | |
content: contentString | |
}); | |
var marker = new google.maps.Marker({ | |
position: uluru, | |
map: map, | |
title: '{title}', | |
icon: '{link image icon}', | |
}); | |
marker.addListener('click', function() { | |
infowindow.open(map, marker); | |
}); | |
}); | |
} | |
</script> | |
<script src="https://maps.googleapis.com/maps/api/js?key={key}&callback=initMap" async defer></script> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment