
zick
User
Feb 21, 2011, 11:35 AM
Post #3 of 8
(4030 views)
Shortcut
|
|
Re: [Jason] Geocode on multi viewer
[In reply to]
|
Can't Post
|
|
Hey Jason, I plugged in the code you provided, but it's returning a generic Google map search page inside the iframe. Do you know if I need to apply for a google API key to get this working? As an alternative, could you explain what I'd need to do if I where to use the javascript to generate the maps. Here's the code I'm using:
///////////////////////////////////// geo records ///////////////////////////////////// list($myRecords, $myMetaData) = getRecords(array( 'tableName' => 'properties', //'tableName' => $GLOBALS['GEOCODER_SAMPLE_TABLENAME'], //'where' => whereRecordNumberInUrl(1), //'limit' => '1', )); $record = @$myRecords[0]; // get first record ///////////////////////////////////// end geo records ///////////////////////////////////// // load records list($propertiesRecords, $propertiesMetaData) = getRecords(array( 'tableName' => 'properties', 'perPage' => '3', //'allowSearch' => false, )); $propertiesRecord = @$propertiesRecords[0]; // get first record <!-- geomap --> <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script> <script type="text/javascript"> function initialize() { var latitude = <?php echo floatval(@$record['latitude']); ?>; var longitude = <?php echo floatval(@$record['longitude']); ?>; var mapCanvasId = 'map_canvas'; if (latitude) { var mapOptions = { mapTypeId: google.maps.MapTypeId.ROADMAP }; var map = new google.maps.Map(document.getElementById(mapCanvasId), mapOptions); var latLng = new google.maps.LatLng(latitude, longitude); var marker = new google.maps.Marker({map: map, position: latLng }); map.setCenter(latLng); map.setZoom(14); } } </script> <!-- /geomap --> <!-- geomap --> <?php if (@$record['latitude']): ?> <br /> <div id="map_canvas" style="width: 400px; height: 240px; float: left; margin: 0px 0px; border: 1px solid #CCC;"></div> <?php endif ?> <?php if (!@$record['latitude']): ?> <?php /*?>show nothing<?php */?> <?php endif ?> <!-- /geomap -->
|