Jump to content

How could I style the echo?


usman07

Recommended Posts

 

OK - you're not passing 'image' as an argument to the createMarker() function.  See how you passed the others, you need to pass image as well.

 

function createMarker(point, name, address, type, image) {
      var marker = new GMarker(point, customIcons[type]);
      var html = "<img src='" + image + "'/><span class='mapinfo'>" + name + "</span> <br/><br/>" + address;
      GEvent.addListener(marker, 'click', function() {
        marker.openInfoWindowHtml(html);
      });
      return marker;
    }

Link to comment
Share on other sites

it must have something to do with this area of code? How can I implement the image in there too? thanks


function load() {
      if (GBrowserIsCompatible()) {
        var map = new GMap2(document.getElementById("map"));
        map.addControl(new GSmallMapControl());
        map.addControl(new GMapTypeControl());
        map.setCenter(new GLatLng(53.823708, -1.513281), 13);

        GDownloadUrl("phpsqlajax_genxml.php", function(data) {
          var xml = GXml.parse(data);
          var markers = xml.documentElement.getElementsByTagName("marker");
          for (var i = 0; i < markers.length; i++) {
            var name = markers[i].getAttribute("name");
            var address = markers[i].getAttribute("address");
            var type = markers[i].getAttribute("type");
            var point = new GLatLng(parseFloat(markers[i].getAttribute("lat")),
                                    parseFloat(markers[i].getAttribute("lng")));
            var marker = createMarker(point, name, address, type);
            map.addOverlay(marker);
          }
        });
      }
    }

Link to comment
Share on other sites

Iv actually got it sorted and it appears now, how do i go about styling it? thanks!

 

Yes, every time you add a new column you'll need to update all applicable code within the script(s).  That's why I was saying this way is over-complicating the process using an external XML generator PLUS a separate XML parser.

 

Style it like I showed you earlier.  Inline within the createMarker() function.  Or by using CSS classes.

Link to comment
Share on other sites

Yeah the problem im having now is when you click the pointer, the first image comes out of the window, then unclick it and click it again, it then stretches. why does it do this, have a look here on this link please: http://www.mumtazproperties.hostei.com/map.html       

and click the yellow pointer, thanks

 

Works fine for me.  The image is contained within the infowindow.

Link to comment
Share on other sites

Always have a width and height declared for an image.  You can do so using css, or to be 100% compatible across the board, use in the inline width/height attributes as some versions of IE will not render the image at all without them.

 

function createMarker(point, name, address, type, image) {
      var marker = new GMarker(point, customIcons[type]);
      var html = "<img src='" + image + "' width='100' height='75' align='left'/><span class='mapinfo'>" + name + "</span> <br/><br/>" + address;
      GEvent.addListener(marker, 'click', function() {
        marker.openInfoWindowHtml(html);
      });
      return marker;
    }

 

Use that block of code.

Link to comment
Share on other sites

You're going to want to move this body tag out of the table.  Have this one with the onload properties replace your regular <body> tag.

<tr>
<th><div id="key"><img src="cutouts/maps/key.jpg" alt=""/></div></th>
  <body onload="load()" onunload="GUnload()">
   <th><div id="map" style="width: 780px; height: 480px"></div></th>
   </tr>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.