Note that there are some explanatory texts on larger screens.

plurals
  1. POTrigger resize of multiple Google Maps v3 on different JQuery UI Tabs
    primarykey
    data
    text
    <p>I am trying to figure out how to pass the latitude and longitude to a google map when my page loads. I am using the following code in the header of my page which works to generate the maps based on the hard-coded latitude and longitude:</p> <pre><code>var map1; var map2; $(document).ready(function(){ google.maps.event.addDomListener(window, 'load', initialize); function initialize() { var myOptions = { zoom: 14, center: new google.maps.LatLng(43.7620537, -79.3516683), mapTypeId: google.maps.MapTypeId.ROADMAP } map1 = new google.maps.Map(document.getElementById("map-canvas-1"),myOptions); var myOptions2 = { zoom: 14, center: new google.maps.LatLng(43.6918950,-79.5310706), mapTypeId: google.maps.MapTypeId.ROADMAP } map2 = new google.maps.Map(document.getElementById("map-canvas-2"),myOptions2); } $("#maptabs").tabs({initialIndex:0,collapsible:true,select: function(){}}); </code></pre> <p>In the body of the page I use the following PHP script to retrieve the correct latitude and longitude that I would like to map:</p> <pre><code>&lt;?php $google_maps_key='ABQIAAAAO-NJVsUOX31LQYJY1LUG8BSOYIDhzYrztjureJjDlAP7PmMi1xQsm9hQ6Z-LRdLFkCtIPr0FQBZxeQ'; $adr = urlencode(DLookup("Property Address", "tblproperties", "`Roll#`=".$id["pntysc"]["pn"]).", ".DLookup("municipalityname", "tblmunicipalities", "municipalitiescounty=".$county)); $url = "http://maps.google.com/maps/geo?q=".$adr."&amp;output=xml&amp;key=$google_maps_key"; $xml = simplexml_load_file($url); $status = $xml-&gt;Response-&gt;Status-&gt;code; if ($status='200') { //address geocoded correct, show results foreach ($xml-&gt;Response-&gt;Placemark as $node) { // loop through the responses $address = $node-&gt;address; $quality = $node-&gt;AddressDetails['Accuracy']; $coordinates = $node-&gt;Point-&gt;coordinates; echo ("Quality: $quality. $address. $coordinates&lt;br/&gt;"); } } else { // address couldn't be geocoded show error message echo ("The address $adr could not be geocoded&lt;br/&gt;"); } ?&gt; </code></pre> <p>Here is my question: How can I populate the maps using the $coordinates variable that is generated in the body of the page, when I have code in the header of the page that needs that particular value? What is the best practice in terms of populating the maps using variable latitude and longitude instead of having those values simply hard-coded?</p> <p>Thanks.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload