943,923 Members | Top Members by Rank

Ad:
Jul 31st, 2009
-1

map.openInfoWindow

Expand Post »
How do i style or put html into a map.openInfoWindow (the bubble on google map).
The reason is because i would like to include a picture and style the text.

The code below is just a normal Java API Map that i use. The key has been removed for the customer.

//<![CDATA[
    function load() {
      if (GBrowserIsCompatible()) {
        var map = new GMap2(document.getElementById("map"));
        map.setCenter(new GLatLng(34.4419, -122.1419), 13);
      }
    }
    //]]>
    </script>
  </head>
  <body onload="load()" onunload="GUnload()">
  <head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
    <title>Google Maps JavaScript API Example</title>
    <script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key="
      type="text/javascript"></script>
    <script type="text/javascript">
    //<![CDATA[
    function load() {
      if (GBrowserIsCompatible()) {
        var map = new GMap2(document.getElementById("map"));
        map.setCenter(new GLatLng(37.246147,-121.957769),10);
      var point = new GPoint(-121.9573, 37.2464);
var marker = new GMarker(point);
map.addOverlay(marker);

map.openInfoWindow(map.getCenter(),
                             document.createTextNode("here is what i want to style"));
                             
      map.addControl(new GMapTypeControl());
      map.addControl(new GLargeMapControl());
      map.addControl(new GOverviewMapControl());
}
    }
    //]]>
    </script>
  </head>
  <body onload="load()" onunload="GUnload()">
    <div id="map" style="width: 700px; height: 300px">
</div>

Again thank you for your help
Last edited by stevenpetersen; Jul 31st, 2009 at 12:41 pm. Reason: basic editing
Similar Threads
Reputation Points: 45
Solved Threads: 1
Junior Poster
stevenpetersen is offline Offline
132 posts
since Jun 2009
Aug 12th, 2009
0

Re: map.openInfoWindow

is there anyone who can edit a google map on this site or does the daniweb just not like me.
Last edited by stevenpetersen; Aug 12th, 2009 at 12:28 pm.
Reputation Points: 45
Solved Threads: 1
Junior Poster
stevenpetersen is offline Offline
132 posts
since Jun 2009
Aug 21st, 2009
0

Re: map.openInfoWindow

This is part of my google script. Hope this helps:

var _map;
var _geocoder;
var _marker;
var _objLocation = null;
var _address = null;

var popupWindows = [];
var gMarkers = [];
var markerCount = 0;

var gAddress = [];
var gDescription = [];

function addItem(pLat, pLong, pTitle, pAddress, pLogo, pDescr) {
    var _mapObject = document.getElementById("googlemap");
    if (_mapObject == null)
        return;

    if (_map == null) {
        _map = new GMap2(_mapObject);
        _map.setCenter(new GLatLng(52.25, 5.4), 9);
        _map.addControl(new GSmallMapControl());
        _map.addControl(new GMapTypeControl());
        _map.checkResize();
    }
    point = new GLatLng(pLat, pLong);

    var customIcon = new GIcon(G_DEFAULT_ICON);
    customIcon.image = "images/marker.png";
    markerOptions = { icon: customIcon, title: pTitle };

    _marker = new GMarker(point, markerOptions);
    if (_marker != null) {
        var param = markerCount;
        GEvent.addListener(_marker, "click", function() {
            showPopup(param);
        });

        gMarkers[markerCount] = _marker;
        _map.addOverlay(_marker);

        gAddress[markerCount] = pAddress;
        gDescription[markerCount] = pDescr;

        popupWindows[markerCount] =
		        '<div><table><tr><td colspan="2" style="height: 80px;">';

        if (pLogo == '') {
            popupWindows[markerCount] += '&nbsp;';
        }
        else {
            popupWindows[markerCount] += '<img src="' + pLogo + '"/>';
        }
		        
        popupWindows[markerCount] +=
		        '</td></tr>' +
		        '<tr><td style="width: 150px; border-right: 1px solid #ddd; padding-right: 10px; height: auto;" valign="top">' +
		        gAddress[markerCount] +
		        '</td><td style="padding-left: 10px;" valign="top">' +
		        gDescription[markerCount] +
		        '</td></tr></table></div>';

        markerCount++;
    }
}

function showPopup(marker) {
    try {
        gMarkers[marker].openInfoWindowHtml(popupWindows[marker]);
    }
    catch (e) { }
}
Sponsor
Featured Poster
Reputation Points: 550
Solved Threads: 731
Bite my shiny metal ass!
pritaeas is offline Offline
4,177 posts
since Jul 2006
Aug 21st, 2009
0

Re: map.openInfoWindow

pritaeas , thank for replying to this! i did not think anyone was going going to reply to it.

Is thee any way you can break the code above down for me so i know how to properly insall and edit it. This code you sent me looks alot different and i do not want to be installing it wrong in projects. I am not to shear on how to install it as well. I also have another google code i am trying to understand in a form if you want to take a crack at it. API new GLatLng help

Thank you for your time and help,
Steven Petersen
Reputation Points: 45
Solved Threads: 1
Junior Poster
stevenpetersen is offline Offline
132 posts
since Jun 2009
Aug 21st, 2009
0

Re: map.openInfoWindow

I'll create a separate working project for you tomorrow. Just a little more patience.

I'm not quite sure what you mean in the other thread. Do you want to add several points to the map ?
Sponsor
Featured Poster
Reputation Points: 550
Solved Threads: 731
Bite my shiny metal ass!
pritaeas is offline Offline
4,177 posts
since Jul 2006
Aug 21st, 2009
0

Re: map.openInfoWindow

Do you want to add several points to the map ?

Yes, but from a list on a txt. or anotherpage.
Attached Thumbnails
Click image for larger version

Name:	Untitled.png
Views:	61
Size:	7.8 KB
ID:	11334  
Reputation Points: 45
Solved Threads: 1
Junior Poster
stevenpetersen is offline Offline
132 posts
since Jun 2009
Aug 22nd, 2009
0

Re: map.openInfoWindow

Hope this will explain things.

A copy of the zip (as rar) can be found here:
http://www.pritaeas.net/public/daniweb/google_map.rar
Attached Files
File Type: zip GoogleMap.zip (3.2 KB, 212 views)
Last edited by pritaeas; Aug 22nd, 2009 at 5:21 am.
Sponsor
Featured Poster
Reputation Points: 550
Solved Threads: 731
Bite my shiny metal ass!
pritaeas is offline Offline
4,177 posts
since Jul 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Configuring Readymade Scripts Forum Timeline: formmail and sendmail on windows/apache
Next Thread in Configuring Readymade Scripts Forum Timeline: Adsense Web Site Blog Script





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC