
sammahoney
User
Jun 19, 2007, 10:49 AM
Post #6 of 6
(11545 views)
Shortcut
|
|
Re: [ross] Google map in _publish_listing.html
[In reply to]
|
Can't Post
|
|
I've somehow managed to get it to work. I was just gonna write above the map 'If you can't see a map there's no location details available' and when I wrote it in I found it only shows when there's no map! Don't know why but I don't really care so long as it works! For anyone else looking to do the same thing: <div id="tcontent3" class="tabcontent" align="center" style="width: 403px; height: 534px"> <span class="style1">There is currently no definite location information for this listing.</span> <script> // Grab the longitude and latitude for this listing var longitude = getLongitude(); var latitude = getLatitude(); // these two functions are used so that listings with no coordinates don't break the map :). function getLongitude() { return $lfield14$; } function getLatitude() { return $lfield13$; } var map = new GMap2(document.getElementById("tcontent3")); map.addControl(new GLargeMapControl()); map.enableContinuousZoom(); map.addControl(new GScaleControl()); map.setCenter(new GLatLng($lfield13$,$lfield14$), 12, G_HYBRID_MAP); // Create a marker whose info window displays the given number. function createMarker(point, html) { var marker = new GMarker(point); // Show this marker's index in the info window when it is clicked. var output = html; return marker; } // the variable html is what will actually appear in the popup bubble. Make sure that any HTML you use here is XHTML strict var html = "<div class='bubble_text'><table valign='top'><tr><td><img src='$listing_url$/images/$thumbnail$' width='$thumbnail_width$'></td><td valign='top' style='padding-top: 5px;'><b>REF: $lfield10$</b><br/><br/>$lfield11$<br/><br/> $lfield5$<br/><br/><font color='#656565' face='Tahoma' onclick=\"MM_openBrWindow('/listman/listings/$listing_file$','Advantage','scrollbars=yes, width=390,height=390')\"><a>Click <a href='javascript:;'>here</a> for more details</a></font></div>"; if (longitude && latitude !=null ) { // the variable point is the longitude and latitude value of a listing. In this example, it is being passed from lfield8 and lfield9. You can use whatever fields you like though. var point = new GPoint(longitude,latitude); var marker = createMarker(point, html); map.addOverlay(marker); } //---------------------------------------------------------------------------- </script> </div>
|