This is what I have in my initialise, as far as setting the location
goes. (Global variable for university is set as: var university = new
google.maps.LatLng(52.94, -1.195);)
if(navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function(position) {
initialLocation = new
google.maps.LatLng(position.coords.latitude,position.coords.longitude);
map.setCenter(initialLocation);
});
} else {
initialLocation = university;
map.setCenter(initialLocation);
}
Does this not mean that if the user clicks deny then it will restore
to setting the map centred about (52.94, -1.195)?
The alerts are there as someone previously asked what the value was.
The last alert is the important one as it shows it is a true Lat Lng
value, showing the parseFloat stuff all worked.
I'm a little confused with the initialise stuff now.. But heres my new
idea:
if("showRoute"==strval($_REQUEST['op']) &&
is_numeric($_REQUEST['id']) )
{
$r = mysql_query ("SELECT * FROM routes where ID = ".
$_REQUEST['id']);
$row = mysql_fetch_assoc($r);
$addmap = true;
}
include ('includes/header_static.php');
I then have within header_static....
function initialize() {
var myOptions = {
zoom: 11,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(document.getElementById("map_canvas"),
myOptions);
// Try W3C Geolocation else set initial location to default
if(navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function(position) {
initialLocation = new
google.maps.LatLng(position.coords.latitude,position.coords.longitude);
map.setCenter(initialLocation);
});
} else {
initialLocation = university;
map.setCenter(initialLocation);
}
if(<?php echo ($addmap) ?>)
{
addMap(<?php $coordinates ?>);
}
} // end of initialize
Im sure Ive gone a bit wrong here, but the idea is that the addMap()
method is within initialize, but only gets called when $addmap is
true. Does this sound ok?
Im sure i've screwed up some of the php stuff here though. Can you
helpme correct this?
Rick
--
You received this message because you are subscribed to the Google Groups
"Google Maps JavaScript API v3" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-maps-js-api-v3?hl=en.