Question

I want to add a map to my site to show a local business, but I don't want to use an image, I wanted to use google maps like I have seen on some websites.

I tried using this:

https://developers.google.com/maps/documentation/javascript/reference#MapOptions

But it doesn't work (do you need to have it up on a server to work? I am just testing it local at the moment)

EDIT: Works now, I don't know what I did but it works.

No correct solution

OTHER TIPS

there are few things you need to add ADD LAT, ADD LONG and ADD YOUR ADDRESS HERE

  <div id="map-canvas" style="height:300px;"></div>
    <script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=true"></script></script>
        <script>
    jQuery(document).ready(function($){
        codeAddress();
    });
    var geocoder;
    var map;
    function initialize() {
  geocoder = new google.maps.Geocoder();
  var latlng = new google.maps.LatLng(ADD LAT, ADD LONG);
  var mapOptions = {
    zoom: 14,
    center: latlng
  }
  map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);
}

function codeAddress() {
  geocoder.geocode( { 'address': 'ADD YOUR ADDRESS HERE'}, function(results, status) {
    if (status == google.maps.GeocoderStatus.OK) {
      map.setCenter(results[0].geometry.location);
      var marker = new google.maps.Marker({
          map: map,
          position: results[0].geometry.location
      });
    } else {
      alert('Geocode was not successful for the following reason: ' + status);
    }
  });
}

google.maps.event.addDomListener(window, 'load', initialize());

    </script>

If you just want to create a map to show where is your business as most the websites the answer is much simpler.

1 - Go to Google maps website and search for the address you want to add.

2 - Once you find the address in the button right of the screen click in settings

3 - Select share a embedded map.

4 - Select the size of the map and you will get something like this on the bar in the side

<iframe src="https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d3192.61190945592!2d174.74475940000002!3d-36.85176959999998!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x6d0d4793eebb1d67%3A0x6830f22a202256c9!2sPonsonby+Rd!5e0!3m2!1sen!2snz!4v1393896861642" width="400" height="300" frameborder="0" style="border:0"></iframe>

Put into your website and job done :)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top