1

I used to use an iFrame to embed a Google Map in a web page, but have recently switched to the JavaScript API to give myself more flexibility.

I am loading the map using the co-ordinates, which is working relatively well.

However, when I view a business on Google maps or in an iFrame for that matter, I can see the business I'm trying to focus on, highlighted in red:

enter image description here

But I can't seem to achieve this with the API -- which sometimes doesn't show the business name at all, let alone highlight it red. I've used DHL as an example here.

enter image description here

How can I 'bind' the map to a business location using the JS API?

My current script looks much like the one provided by the Google walkthrough pages:

function initialize() {
    var longLat = { lat: 52.8004265, lng: -1.6334708},
        mapOptions = {
          center: longLat,
          zoom: 18,
          scrollwheel: false,
        };
    var map = new google.maps.Map(
        document.getElementById('map-canvas'),
        mapOptions
    );
    var marker = new google.maps.Marker({
        position: longLat,
        map: map,
        title:"DHL"
    });
}
google.maps.event.addDomListener(window, 'load', initialize);
George
  • 36,413
  • 9
  • 66
  • 103

1 Answers1

0

You can attach infowindow to your marker and display the business name in that way. Here is an example And here's another example using customized label as a marker, and it can contain the business name. Example

Community
  • 1
  • 1
so_jin_ee
  • 802
  • 6
  • 7