Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- url.com?postcode=XXXXXX
- center: new google.maps.LatLng(longitude, latitude)
- var postcodeValue = $('#map').attr('data-postcode');
- function latLong(location, callback) {
- var geocoder = new google.maps.Geocoder();
- var address = location;
- var longitude;
- var latitude;
- geocoder.geocode({
- 'address': address
- }, function (results, status) {
- if (status == google.maps.GeocoderStatus.OK) {
- latitude = results[0].geometry.location.lat();
- longitude = results[0].geometry.location.lng();
- callback(latitude, longitude);
- }
- });
- }
- latLong(postcodeValue, function(lat, lon) {
- console.log(lat);
- console.log(lon);
- });
- var options = {
- mapTypeControlOptions: {
- mapTypeIds: [ 'Styled']
- },
- center: new google.maps.LatLng(latLong),
- zoom: 12,
- mapTypeId: 'Styled',
- disableDefaultUI: true,
- draggable: false,
- disableDoubleClickZoom: true
- };
- var div = document.getElementById('map');
- var map = new google.maps.Map(div, options);
- var styledMapType = new google.maps.StyledMapType(styles);
- map.mapTypes.set('Styled', styledMapType);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement