Advertisement
Guest User

Untitled

a guest
Oct 30th, 2014
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. url.com?postcode=XXXXXX
  2.  
  3. center: new google.maps.LatLng(longitude, latitude)
  4.  
  5. var postcodeValue = $('#map').attr('data-postcode');
  6. function latLong(location, callback) {
  7. var geocoder = new google.maps.Geocoder();
  8. var address = location;
  9. var longitude;
  10. var latitude;
  11. geocoder.geocode({
  12. 'address': address
  13. }, function (results, status) {
  14. if (status == google.maps.GeocoderStatus.OK) {
  15. latitude = results[0].geometry.location.lat();
  16. longitude = results[0].geometry.location.lng();
  17. callback(latitude, longitude);
  18. }
  19. });
  20. }
  21.  
  22. latLong(postcodeValue, function(lat, lon) {
  23. console.log(lat);
  24. console.log(lon);
  25. });
  26.  
  27. var options = {
  28. mapTypeControlOptions: {
  29. mapTypeIds: [ 'Styled']
  30. },
  31. center: new google.maps.LatLng(latLong),
  32. zoom: 12,
  33. mapTypeId: 'Styled',
  34. disableDefaultUI: true,
  35. draggable: false,
  36. disableDoubleClickZoom: true
  37. };
  38.  
  39. var div = document.getElementById('map');
  40. var map = new google.maps.Map(div, options);
  41. var styledMapType = new google.maps.StyledMapType(styles);
  42.  
  43. map.mapTypes.set('Styled', styledMapType);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement