![]() |
|
|||||||
![]() |
Realty Manager Tutorial: Display full listings with Google Maps
Update: Added error checking into the template javascript code so that listings without longitude and langitude entered will not generate an error. This tutorial outlines setting up a Google Map with all of your property listings represented by markers in the map. You can see this in action in this example: Listings Map View example Let us know if you need assistance setting this up. You can post to the forum or fill out a support request, or even give us a call. Note: If you want to simply link to a Google Map of a single property from the individual listing detail pages (similar to the Yahoo Maps links in the default templates), refer to this forum post: http://www.interactivetools.com/iforum/_P42271
1. XHTML strict and iframes The easiest way to get things going is using an iframe to make it appear on your pages. Note that the map itself needs to be on a page that is valid as XHTML strict. The iframe page will get created on the fly by a search_results.html template called _google_map.html.Copy the code below and save it as _google_map.html. Before uploading it into your template directory, there are a couple key areas in this template that you'll want to adjust for your own websites (see the following steps). _google_map.html template:2. Google Maps API Key The API key is a unique number generated specifically for your website. You can generate your own API key here: http://maps.google.com/apis/maps/signup.html Once you've generated it, you'll need to paste your key into line 6 of the sample template: <script src="http://maps.google.com/maps?file=api&v=1&key=YOUR GOOGLE API KEY" type="text/javascript"></script> 3. Map Centering and Zoom Line 46 of the template tells the map to center on a specific point in the world. You specify that point using longitude and latitude coordinates and then tell it a zoom level. In the example you'll see this: map.centerAndZoom(new GPoint(-123.07159423828125,49.19067925930702), 8);-123.07159423828125 is the longitude 49.19067925930702 is the latitude 8 is the zoom level The best way to find the longitude and latitude for your desired center point is using the utility in the web page below (just click a point on the map and its coordinates appear at the bottom): http://mapki.com/index.php?title=Get_Lon_LatOnce you have those coordinates, you'll need to experiment with the zoom level to find something that suits your listings - the appropriate level depends on how wide an area your listings are in. 4. Template Cells - popup bubbles Each "templatecell" in the example has a line that starts with "var html". This controls the content that appears in the info bubble that appears above each listing on the map. There are two very important things to note: a) the content here also needs to be XHTML
strict In the example, the preview image (when there is one available), the price ($lfield3$), the address ($lfield2$) and a brief comment ($lfield10$) are being passed to the popup bubble. One thing to keep in mind here is that any text you use isn't going to wrap to the next line automatically. You'll need to use <br/> and <p/> tags. You can use any field in here you like but just remember the two points mentioned above. After you have finished modifying the template, upload it into your Listings Manager template directory. 5. Template Cells - longitudes and latitudes for each home Similar to the "center and zoom" line you looked at in step 3, the coordinates of each house on your map are done with longitude ($lfield8$) and latitude ($lfield9$). These two fields should be configured in Listings Manager to store the coordinates (if you use different field numbers than 8 and 9, modify the _google_map.html template to reflect your alternative field numbers). To set these up: To appear in the map, a listing will need the Longitude and Latitude values. Listings without coordinates simply won't show up. When adding coordinates to a listing, the fields will look something like this:
6. Search Query to dynamically create your listings map As the last step, add an iframe (with a search query using the _google_map.html template) to the pages that you want to display the map in. For example, you could put it somewhere in your Listings Index template, or even on a web page outside of Realty Manager. Here is an example of the iframe code to use (update the code with your path to search.cgi): <iframe src="/cgi-bin/listman/exec/search.cgi?search=1&template=_google_map.html" width=500 height=515></iframe> And that's about it. By using the _google_map.html template shown above, the map will be dynamically updated as listings are added or removed. For all the advanced users out there, Google has an excellent resource for the Google Maps API site. It has tones of examples and the discussion groups have some amazing add-ons you may want to try out: http://maps.google.com/apis/maps/Have a go at it and let us know what you all think. We are here to help too so feel free to send in any questions you have about this. We also offer a Priority Consulting service if you would prefer for us to get the map setup for you. To inquire, send us an email or call 1-800-752-0455. Did this "How to" make sense? Send us your feedback, or let us know if you're using something like this on your installation of Realty Manager and we'll link to it as an example. |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||