tags:

views:

11937

answers:

2

I'm working on a website of a client, a local church. I've embedded a Google Map using the Link feature on the Maps page. The info window on the map includes "Reviews," and the church is concerned about this. Is there a way to remove that from the info window? I don't want to remove any reviews themselves, just that link on the info window?

Is this possible? Are there any other customization options (besides the size) one can manipulate via the query string?

A: 

I think I found the answer to my own question. The info window itself can't be modified, but by linking to the map for the address itself rather than the church as a business entity does the trick. The driving directions link is still there and that's mostly all they wanted.

Michael Itzoe
+4  A: 

Nearly 2 years ago, I created a custom map with complete control over the contents of the bubble, using the API and some code manipulation. Click on the above link for a demo. I've cleaned up the code for this answer, although to implement you'll need to replace all YOUR__BLANK__HERE text with the appropriate values.

Step 1: Call the gMaps API

<script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=YOUR_API_KEY_HERE"
  type="text/javascript">
</script>

Step 2: In the body of your document, create an element with id "map". Size and position it with CSS. It requires a height and width.

 <div id="map" class="content"></div>

Step 3: After the div has been defined in the DOM, it is safe to insert the following script tag:

note: in xhtml, <script> elements are only allowed in the <head> element, so you may have to insert the following into an anonymous function that is then tied to an onload or onready event.

<script type="text/javascript">
//<![CDATA[

// Check to see if this browser can run the Google API
if (GBrowserIsCompatible()) {

  var gmarkers = [];
  var htmls = [];
  var to_htmls = [];
  var from_htmls = [];
  var i=0;

  // A function to create the marker and set up the event window
  function createMarker(point,name,html) {
    var marker = new GMarker(point);

    // The info window version with the "to here" form open
    to_htmls[i] = html +
       '<br />Start address:<form action="http://maps.google.com/maps" method="get">' +
       '<input type="text" SIZE=40 MAXLENGTH=40 name="saddr" id="saddr" value="" /><br>' +
       '<INPUT value="Get Directions" TYPE="SUBMIT">' +
       '<input type="hidden" name="daddr" value="' + point.lat() + ',' + point.lng() + 
              // "(" + name + ")" + 
       '"/>';
    // The inactive version of the direction info
    html = html + '<br><a href="javascript:tohere('+i+')">Get Directions<'+'/a>';

    GEvent.addListener(marker, "click", function() {
      marker.openInfoWindowHtml(html);
    });
    gmarkers[i] = marker;
    htmls[i] = html;
    i++;
    return marker;
  }

  // functions that open the directions forms
  function tohere(i) {
    gmarkers[i].openInfoWindowHtml(to_htmls[i]);
  }

  // Display the map, with some controls and set the initial location 
  var map = new GMap2(document.getElementById("map"));
  map.setCenter(new GLatLng(
    YOUR_LATITUDE_HERE,
    YOUR_LONGITUDE_HERE
    ), 
    YOUR_ZOOM_LEVEL_HERE // a value of 13 worked for me
  );

  // Set up one marker with an info window 
  var marker = createMarker(
    new GLatLng(
      YOUR_LATITUDE_HERE,
      YOUR_LONGITUDE_HERE
    ),
    'YOUR_MARKER_NAME_HERE',
    '<i>YOUR_HTML_HERE<'+'/i>');

  /* repeat the process to add more markers
  map.addOverlay(marker);
  var marker = createMarker(
    new GLatLng(
      YOUR_LATITUDE_HERE,
      YOUR_LONGITUDE_HERE
    ),
    'YOUR_MARKER_NAME_HERE',
    '<i>YOUR_HTML_HERE<'+'/i>');
  map.addOverlay(marker);*/
}


// display a warning if the browser was not compatible
else {
  alert("Sorry, the Google Maps API is not compatible with this browser");
}

// This Javascript is based on code provided by the
// Blackpool Community Church Javascript Team
// http://www.commchurch.freeserve.co.uk/   
// http://www.econym.demon.co.uk/googlemaps/

//]]>
</script>

Using this code, the bubble contains the html you specify in YOUR_HTML_HERE plus a link to Get Directions, which (when clicked) turns into a textbox asking for a starting address. The result of the query, unfortunately, opens in a new browser window (since, at time of original publishing the API did not include directions capabilities)

yaauie