Maps question

This works on my desktop browser:
http://code.google.com/apis/maps/documentation/javascript/basics.html#DetectingUserLocation
[import]uid: 33608 topic_id: 17147 reply_id: 66169[/import]

did you know how to use both this functions on a same map?

I always get error and my map don’t run =S [import]uid: 23063 topic_id: 17147 reply_id: 66172[/import]

I’m trying this:

  
  
[html]  
  
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">  
<meta http-equiv="content-type" content="text/html; charset=UTF-8">

<title>Google Maps JavaScript API v3 Example: Directions Simple</title>
  
<link href="http://code.google.com/apis/maps/documentation/javascript/examples/default.css" rel="stylesheet" type="text/css">
  
<script type="text/javascript" src="//maps.googleapis.com/maps/api/js?sensor=true"></script>  
<script type="text/javascript"><br> var directionDisplay;<br> var directionsService = new google.maps.DirectionsService();<br> var map;<br> <br> var initialLocation;<br> var siberia = new google.maps.LatLng(-29.833273,-50.056543);<br> var newyork = new google.maps.LatLng(-29.833273,-50.056543);<br> var browserSupportFlag = new Boolean();<br> // Try W3C Geolocation (Preferred)<br> if(navigator.geolocation) {<br> browserSupportFlag = true;<br> navigator.geolocation.getCurrentPosition(function(position) {<br> initialLocation = new google.maps.LatLng(position.coords.latitude,position.coords.longitude);<br> map.setCenter(initialLocation);<br> }, function() {<br> handleNoGeolocation(browserSupportFlag);<br> });<br> // Try Google Gears Geolocation<br> } else if (google.gears) {<br> browserSupportFlag = true;<br> var geo = google.gears.factory.create('beta.geolocation');<br> geo.getCurrentPosition(function(position) {<br> initialLocation = new google.maps.LatLng(position.latitude,position.longitude);<br> map.setCenter(initialLocation);<br> }, function() {<br> handleNoGeoLocation(browserSupportFlag);<br> });<br> // Browser doesn't support Geolocation<br> } else {<br> browserSupportFlag = false;<br> handleNoGeolocation(browserSupportFlag);<br> }<br> <br> function handleNoGeolocation(errorFlag) {<br> if (errorFlag == true) {<br> alert("Geolocation service failed.");<br> initialLocation = newyork;<br> } else {<br> alert("Your browser doesn't support geolocation. We've placed you in Siberia.");<br> initialLocation = siberia;<br> }<br> map.setCenter(initialLocation);<br> }<br><br> function initialize() {<br> directionsDisplay = new google.maps.DirectionsRenderer();<br> var chicago = new google.maps.LatLng(-29.868336,-50.136452);<br> var myOptions = {<br> zoom:7,<br> mapTypeId: google.maps.MapTypeId.ROADMAP,<br> center: chicago<br> }<br> map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);<br> directionsDisplay.setMap(map);<br> }<br> <br> function calcRoute() {<br> var start = document.getElementById("start").value;<br> var end = document.getElementById("end").value;<br> var request = {<br> origin:start, <br> destination:end,<br> travelMode: google.maps.DirectionsTravelMode.DRIVING<br> };<br> directionsService.route(request, function(response, status) {<br> if (status == google.maps.DirectionsStatus.OK) {<br> directionsDisplay.setDirections(response);<br> }<br> });<br> }<br></script>  
  
  

  
**Start:**   
  
<select id="start" onchange="calcRoute();"><br> <option value=""> </option>
<br> <option value="(initialLocation)">User Location</option>
<br> <br></select>  
**End:**   
<select id="end" onchange="calcRoute();"><br> <option value=""> </option>
<br> <option value="(-29.833273,-50.056543)">Maori Beach Club</option>
<br><br></select>  

  

  
  
[/html]  

but I’m always getting an error from GeoLocalization
any idea? [import]uid: 23063 topic_id: 17147 reply_id: 66177[/import]

Read my post above, the API source in your code is wrong.
use:

[code]

[/code] [import]uid: 33608 topic_id: 17147 reply_id: 66180[/import]

still can’t make it work, now I don’t get any error msg

[html]

[html]

Google Maps JavaScript API v3 Example: Directions Simple

Start:




User Location



End:



Maori Beach Club


[/html]
[/html]

I can use “initialLocation” in this line “User Location” to put user locate lat/log ? [import]uid: 23063 topic_id: 17147 reply_id: 66185[/import]

I’m having problem with current user locate code

EDIT: nevermind dude, in iphone works fine =S

but i’m still cant trace the user current locate and “maori”

any idea? [import]uid: 23063 topic_id: 17147 reply_id: 66189[/import]

You have the initialize() function set twice. However, it doesnt work on my computer even after fixing that, so you might have another error on the code somewhere.
I’m not a google api expert in any way. Hopefully someone else can help you, or you can try on another forum, such as a google maps api related website or on stackoverflow.com. [import]uid: 33608 topic_id: 17147 reply_id: 66286[/import]

thank you anyway

you help me alot ^^

thanks [import]uid: 23063 topic_id: 17147 reply_id: 66291[/import]