Customize Google Maps Info Window?

I work for a client website, a local church. I have applied a google map using the Link function on the Maps page. The information box on the map includes Views, and the church is concerned about that. Is there a way to remove this from the info window? I don't want to delete any reviews myself, just this link in the info window?

Is it possible? Are there other customization options (besides size) that can be manipulated with the query string?

-1


source to share


2 answers


Almost 2 years ago I created a custom map with full control over the bubble content using API and some code manipulation.Click on the above link for a demo. I've cleaned up the code for this answer, although for implementation you will need to replace all YOUR__BLANK__HERE text with the appropriate values.

Step 1: Call API gMaps

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

      

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



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

      

Step 3: After the div has been defined in the DOM, the following script tag can be inserted:

<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 that you specify in YOUR_HTML_HERE, as well as a Get Directions link, which (when clicked) turns into a text box asking for the start address. The result of the query, unfortunately, opens in a new browser window (because at the time of initial publication, the API did not include hint capabilities)

+6


source


I think I found the answer to my question. The info window itself cannot be changed, but by binding to the map for the address itself, not for the church, as the business entity is doing the trick. The route link is still there and that's basically everything they wanted.



0


source







All Articles