Advertisement
Guest User

Untitled

a guest
Jul 7th, 2017
295
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. function getLatLng() {
  2. return $.ajax({
  3. url: 'https://maps.googleapis.com/maps/api/geocode/json?address=germany&sensor=false',
  4. type: 'GET',
  5. dataType: 'json',
  6. });
  7. }
  8.  
  9. getLatLng().done(function(data) {
  10. var latlng = [data.results[0].geometry.location.lat, data.results[0].geometry.location.lng];
  11.  
  12. function initMap() {
  13.  
  14. var styledMapType = new google.maps.StyledMapType(
  15. [],
  16. {name: 'Styled Map'});
  17.  
  18. var map = new google.maps.Map(document.getElementById('map'), {
  19. center: {lat: latlng[0], lng: latlng[1]},
  20. zoom: 11,
  21. mapTypeControlOptions: {
  22. mapTypeIds: ['roadmap', 'satellite', 'hybrid', 'terrain',
  23. 'styled_map']
  24. }
  25. });
  26.  
  27. map.mapTypes.set('styled_map', styledMapType);
  28. map.setMapTypeId('styled_map');
  29. }
  30. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement