Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 13 of 13
  1. #1
    Regular Coder
    Join Date
    Apr 2013
    Posts
    158
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Question Google maps redraws map for each of my new location and then crashes?!

    Hi,

    On my app here: http://www.jbiddulph.com/pubs1/

    Select a Letter A-Z, then select a town, when you select a pub, the map should load and show your location and the pubs location with a line drawing between the 2, good! it also refreshed your LAT / LONG but I think the map redraws and eventually crashes?!

    Please help!!

    Maybe I could add a button to START MY JOURNEY and another to PAUSE MY JOURNEY which just move the marker and not redraw the map?!

    here is my code below:

    Code:
    // MAP
    var map;
    // var localSearch = new GlocalSearch();
    // Wait for Cordova to load
    //
    // document.addEventListener("deviceready", onDeviceReady, false);
    var myaddress;
    var watchID = null;
    var mypoint;
    // Cordova is ready
    //
    // PhoneGap is ready
    //
    
    
    //line
    var location1;
    var location2;
    var address1;
    var address2;
    var latlng;
    var geocoder;
    var distance;
    
    
    function checkInternet() {
        var online = window.navigator.onLine;
        if (!online) {
            alert('Please check your internet connection and try again.');
        }
    }
    // Update every 3 seconds
                   
    // finds the coordinates for the two locations and calls the showMap() function
    
    function initialize() {
    	
        geocoder = new google.maps.Geocoder(); // creating a new geocode object
        // getting the two address values
        address2 = document.getElementById("postcode").value;
        // finding out the coordinates
        if (geocoder) {
            geocoder.geocode({
                             'address': address2
                             }, function(results, status) {
                             if (status == google.maps.GeocoderStatus.OK) {
                             //location of second address (latitude + longitude)
                             location2 = results[0].geometry.location;
                             // calling the showMap() function to create and show the map
                             showMap();
                             } else {
                             alert("Geocode was not successful for the following reason: " + status);
                             }
                             });
        }
        
    }
    
    // creates and shows the map
    
    function showMap() {
    	var marker1;
    	var options = {
            frequency: 3000
            };
            watchID = navigator.geolocation.watchPosition(onSuccess, onError, options);
    
    	function onSuccess(position) {
            var element = document.getElementById('geolocation');
        //	element.innerHTML = 'Latitude: ' + position.coords.latitude + '<br />' + 'Longitude: ' + position.coords.longitude + '<br />' + '<hr />' + element.innerHTML;
            mypoint = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);
            /* marker1.setPosition(mypoint); */
                
        var myaddress;
            
        // onSuccess Geolocation
        //
        
        
        myaddress = mypoint;
        
        
        //alert("My Location: "+myaddress+" Location1: "+location1+ "Pub Location "+location2);
        // center of the map (compute the mean value between the two locations)
        latlng = new google.maps.LatLng((myaddress.lat() + location2.lat()) / 2, (myaddress.lng() + location2.lng()) / 2);
        // set map options
        // set zoom level
        // set center
        // map type
        var mapOptions = {
        zoom: 15,
        center: latlng,
        mapTypeId: google.maps.MapTypeId.ROADMAP
        };
        // create a new map object
        // set the div id where it will be shown
        // set the map options
        map = new google.maps.Map(document.getElementById("map"), mapOptions);
        // show route between the points
        directionsService = new google.maps.DirectionsService();
        directionsDisplay = new google.maps.DirectionsRenderer({
                                                               suppressMarkers: true,
                                                               suppressInfoWindows: true
                                                               });
        directionsDisplay.setMap(map);
        var request = {
        origin: myaddress,
        destination: location2,
        travelMode: google.maps.DirectionsTravelMode.DRIVING
        };
        directionsService.route(request, function(response, status) {
                                if (status == google.maps.DirectionsStatus.OK) {
                                directionsDisplay.setDirections(response);
                                distance = "The distance between the two points on the chosen route is: " + response.routes[0].legs[0].distance.text;
                                distance += "<br/>The aproximative driving time is: " + response.routes[0].legs[0].duration.text;
                                document.getElementById("distance_road").innerHTML = distance;
                                }
                                });
        // show a line between the two points
        var line = new google.maps.Polyline({
                                            map: map,
                                            path: [myaddress, location2],
                                            strokeWeight: 7,
                                            strokeOpacity: 0.8,
                                            strokeColor: "#FFAA00"
                                            });
        // Define Marker properties
        var image2 = new google.maps.MarkerImage('http://cdn.mapsmarker.com/wp-content/uploads/leaflet-maps-marker-icons/bar.png',
                                                 // This marker is 129 pixels wide by 42 pixels tall.
                                                 new google.maps.Size(32, 37),
                                                 // The origin for this image is 0,0.
                                                 new google.maps.Point(0, 0),
                                                 // The anchor for this image is the base of the flagpole at 18,42.
                                                 new google.maps.Point(18, 37));
        // create the markers for the two locations
        var marker1 = new google.maps.Marker({
                                             map: map,
                                             position: myaddress,
                                             title: "I am here!"
                                             });
        marker1.setPosition(myaddress);
        var marker2 = new google.maps.Marker({
                                             map: map,
                                             position: location2,
                                             title: "Second location",
                                             icon: image2
                                             });
        // create the text to be shown in the infowindows
        var text1 = '<div id="content">' + '<h2 id="firstHeading">I am here!</h1>' + '</div>';
        var text2 = '<div id="content">' + '<h2 id="firstHeading">The Pub</h1>' + '</div>';
        // create info boxes for the two markers
        var infowindow1 = new google.maps.InfoWindow({
                                                     content: text1
                                                     });
        var infowindow2 = new google.maps.InfoWindow({
                                                     content: text2
                                                     });
        // add action events so the info windows will be shown when the marker is clicked
        google.maps.event.addListener(marker1, 'click', function() {
                                      infowindow1.open(map, marker1);
                                      });
        google.maps.event.addListener(marker2, 'click', function() {
                                      infowindow2.open(map, marker2);
                                      });
        // compute distance between the two points
        var R = 6371;
        var dLat = toRad(location2.lat() - myaddress.lat());
        var dLon = toRad(location2.lng() - myaddress.lng());
        var dLat1 = toRad(myaddress.lat());
        var dLat2 = toRad(location2.lat());
        var a = Math.sin(dLat / 2) * Math.sin(dLat / 2) + Math.cos(dLat1) * Math.cos(dLat1) * Math.sin(dLon / 2) * Math.sin(dLon / 2);
        var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
        var d = R * c;
        document.getElementById("distance_direct").innerHTML = "<br/>The distance between the two points (in a straight line) is: " + d;
    }
    }
    function toRad(deg) {
        return deg * Math.PI / 180;
    }
    //end line
    
    
        // onError Callback receives a PositionError object
        //
        
        function onError(error) {
            alert('code: ' + error.code + '\n' + 'message: ' + error.message + '\n');
        }
    
    
    
    
    
    
    
    
    
    
    
    //getTownpubmap
    function getTownpubmap(id) {
        var url = "http://www.mypubspace.com/pubsmobile/gettownpubs.php?rsTown=" + id;
        $.getJSON(url, function(json) {
                  i = 1;
                  $.each(json, function(k, v) {
                         geocoder = new google.maps.Geocoder(); // creating a new geocode object
                         if (geocoder) {
                         geocoder.geocode({
                                          'address': v.rsPostCode
                                          }, function(results, status) {
                                          if (status == google.maps.GeocoderStatus.OK) {
                                          pubpostcode = v.rsPostCode;
                                          pubpostcode = results[0].geometry.location;
                                          showMap();
                                          } else {
                                          alert("Geocode was not successful for the following reason: " + status);
                                          }
                                          });
                         }
                         
                         function showMap() {
                         latlng = new google.maps.LatLng((myaddress.lat() + pubpostcode.lat()) / 2, (myaddress.lng() + pubpostcode .lng()) / 2);
                         var pubimage = new google.maps.MarkerImage('http://cdn.mapsmarker.com/wp-content/uploads/leaflet-maps-marker-icons/bar.png', new google.maps.Size(32, 37), new google.maps.Point(0, 0), new google.maps.Point(18, 37));
                         var pubmarker = new google.maps.Marker({
                                                              map: map,
                                                              position: pubpostcode,
                                                              title: "Second location",
                                                              icon: pubimage
                                                              });
                         var pubtext = '<div id="content">' + '<h2 id="firstHeading">'+ v.rsPubName +'</h1>' + '</div>';
                         var pubinfowindow = new google.maps.InfoWindow({
                                                                      content: pubtext
                                                                      });
                         google.maps.event.addListener(pubmarker, 'click', function() {
                                                       pubinfowindow.open(map, pubmarker);
                                                       });
                         i++;
                         }
                         });
                  });
        var mapOptions = {
        zoom: 15,
        center: pubpostcode,
        mapTypeId: google.maps.MapTypeId.ROADMAP
        };
        map = new google.maps.Map(document.getElementById("map"), mapOptions);
        
    }

  • #2
    Regular Coder
    Join Date
    Apr 2013
    Posts
    158
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Unhappy

    Can anyone help me on this please???

  • #3
    Senior Coder
    Join Date
    Jan 2011
    Location
    Missouri
    Posts
    4,712
    Thanks
    25
    Thanked 660 Times in 659 Posts
    I went to the website and got a JS alert saying "not supported"

    Loaded your JS (I'm guessing that your posted code is all JS) and ran it. Blank page.

    Could you please help us out and post all the needed code.
    Evolution - The non-random survival of random variants.

    "If you leave hydrogen alone, for long enough, it begins to think about itself."

  • #4
    Regular Coder
    Join Date
    Apr 2013
    Posts
    158
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Question

    I have removed the error, I think I am calling a new google maps every time?! Just need to move the markers not redraw the map?!

  • #5
    Regular Coder
    Join Date
    Apr 2013
    Posts
    158
    Thanks
    3
    Thanked 0 Times in 0 Posts
    is anyone able to help me on this please?

  • #6
    Regular Coder
    Join Date
    Apr 2013
    Posts
    158
    Thanks
    3
    Thanked 0 Times in 0 Posts
    ok so using the following code I got my marker moving: http://www.jbiddulph.com/pubs1

    Code:
    // MAP
    var map;
    // var localSearch = new GlocalSearch();
    // Wait for Cordova to load
    //
    // document.addEventListener("deviceready", onDeviceReady, false);
    
    var location2;
    var address2;
    var latlng;
    var geocoder;
    var distance;
    
    function checkInternet() {
    	var online = window.navigator.onLine;
    	if (!online) {
    		alert('Please check your internet connection and try again.');
    	}
    }
    // Update every 3 seconds
    // finds the coordinates for the two locations and calls the showMap() function
    
    function initialize() {
    	geocoder = new google.maps.Geocoder(); // creating a new geocode object
    	// getting the two address values
    	address2 = document.getElementById("postcode").value;
    	// finding out the coordinates
    	if (geocoder) {
    		geocoder.geocode({
    			'address': address2
    		}, function(results, status) {
    			if (status == google.maps.GeocoderStatus.OK) {
    				//location of second address (latitude + longitude)
    				location2 = results[0].geometry.location;
    				// calling the showMap() function to create and show the map
    				initLocationProcedure();
    			} else {
    				alert("Geocode was not successful for the following reason: " + status);
    			}
    		});
    	}
    }
    // creates and shows the map
    
    
    
                var map,
                    currentPositionMarker,
                    mapCenter = new google.maps.LatLng(40.700683, -73.925972),
                    map;
    
                function initializeMap()
                {
                    map = new google.maps.Map(document.getElementById('map'), {
                       zoom: 18,
                       center: mapCenter,
                       mapTypeId: google.maps.MapTypeId.ROADMAP
                     });
                }
    
                function locError(error) {
                    // the current position could not be located
                    alert("The current position could not be found!");
                }
    
                function setCurrentPosition(pos) {
                    currentPositionMarker = new google.maps.Marker({
                        map: map,
                        position: new google.maps.LatLng(
                            pos.coords.latitude,
                            pos.coords.longitude
                        ),
                        title: "Current Position"
                    });
                    map.panTo(new google.maps.LatLng(
                            pos.coords.latitude,
                            pos.coords.longitude
                        ));
                }
    
                function displayAndWatch(position) {
                    // set current position
                    setCurrentPosition(position);
                    // watch position
                    watchCurrentPosition();
                }
    
                function watchCurrentPosition() {
                    var positionTimer = navigator.geolocation.watchPosition(
                        function (position) {
                            setMarkerPosition(
                                currentPositionMarker,
                                position
                            );
                        });
                }
    
                function setMarkerPosition(marker, position) {
                    marker.setPosition(
                        new google.maps.LatLng(
                            position.coords.latitude,
                            position.coords.longitude)
                    
                    );
                    
                }
    
    
                function initLocationProcedure() {
                    initializeMap();
                    if (navigator.geolocation) {
                        navigator.geolocation.getCurrentPosition(displayAndWatch, locError);
                    } else {
                        alert("Your browser does not support the Geolocation API");
                    }
                }
    
                $(document).ready(function() {
                    
                    initLocationProcedure();
                    
                });
    I would now like to draw a line between the two points: position and location2 and say how far it is using the following code but not sure where it should go or if it should be wrapped in a function or if I can my API key inside or outside of the area?!

    Code:
    // show route between the points
    		directionsService = new google.maps.DirectionsService();
    		directionsDisplay = new google.maps.DirectionsRenderer({
    			suppressMarkers: true,
    			suppressInfoWindows: true
    		});
    		directionsDisplay.setMap(map);
    		var request = {
    			origin: position,
    			destination: location2,
    			travelMode: google.maps.DirectionsTravelMode.DRIVING
    		};
    		
    		directionsService.route(request, function(response, status) {
    			if (status == google.maps.DirectionsStatus.OK) {
    				directionsDisplay.setDirections(response);
    				distance = "The distance between the two points on the chosen route is: " + response.routes[0].legs[0].distance.text;
    				distance += "<br/>The aproximative driving time is: " + response.routes[0].legs[0].duration.text;
    				document.getElementById("distance_road").innerHTML = distance;
    			}
    		});
    		// show a line between the two points
    		var line = new google.maps.Polyline({
    			map: map,
    			path: [position, location2],
    			strokeWeight: 7,
    			strokeOpacity: 0.8,
    			strokeColor: "#FFAA00"
    		});
    		// Define Marker properties
    		var image2 = new google.maps.MarkerImage('http://cdn.mapsmarker.com/wp-content/uploads/leaflet-maps-marker-icons/bar.png',
    		// This marker is 129 pixels wide by 42 pixels tall.
    		new google.maps.Size(32, 37),
    		// The origin for this image is 0,0.
    		new google.maps.Point(0, 0),
    		// The anchor for this image is the base of the flagpole at 18,42.
    		new google.maps.Point(18, 37));
    		// create the markers for the two locations
    		
    		
    		var marker2 = new google.maps.Marker({
    			map: map,
    			position: location2,
    			title: "Second location",
    			icon: image2
    		});
    		// create the text to be shown in the infowindows
    		var text1 = '<div id="content">' + '<h2 id="firstHeading">I am here!</h1>' + '</div>';
    		var text2 = '<div id="content">' + '<h2 id="firstHeading">The Pub</h1>' + '</div>';
    		// create info boxes for the two markers
    		var infowindow1 = new google.maps.InfoWindow({
    			content: text1
    		});
    		var infowindow2 = new google.maps.InfoWindow({
    			content: text2
    		});
    		// add action events so the info windows will be shown when the marker is clicked
    		google.maps.event.addListener(marker1, 'click', function() {
    			infowindow1.open(map, marker1);
    		});
    		google.maps.event.addListener(marker2, 'click', function() {
    			infowindow2.open(map, marker2);
    		});
    		// compute distance between the two points
    		var R = 6371;
    		var dLat = toRad(location2.lat() - position.lat());
    		var dLon = toRad(location2.lng() - position.lng());
    		var dLat1 = toRad(position.lat());
    		var dLat2 = toRad(location2.lat());
    		var a = Math.sin(dLat / 2) * Math.sin(dLat / 2) + Math.cos(dLat1) * Math.cos(dLat1) * Math.sin(dLon / 2) * Math.sin(dLon / 2);
    		var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
    		var d = R * c;
    		document.getElementById("distance_direct").innerHTML = "<br/>The distance between the two points (in a straight line) is: " + d;

  • #7
    Senior Coder
    Join Date
    Jan 2011
    Location
    Missouri
    Posts
    4,712
    Thanks
    25
    Thanked 660 Times in 659 Posts
    if I can my API key inside or outside of the area?!
    Just spent this noon on google. Don't need API key with new API ver 3...

    Here is a map with start and finish points and directions
    Code:
    <!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="UTF-8">
    <title></title>
    <style type="text/css">
    #map {
    	width: 500px;
    	height: 400px;
    	float: left;
    	margin-right: 20px;
    }
    #directions	{
    	width: 300px;
    	height: 400px;
    	float: left;
    	overflow:auto;
    }
    </style>
    <script src="https://maps.googleapis.com/maps/api/js?sensor=false"></script>
    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
    <script>
    $(document).ready(function(){
    	var directionsService = new google.maps.DirectionsService();
    	var markers = [];
    	var myLatlng = new google.maps.LatLng(36.52443, -91.98488);
    	var mapOptions = {zoom: 10, center: myLatlng, mapTypeId: google.maps.MapTypeId.ROADMAP}
    	var map = new google.maps.Map($("#map").get(0), mapOptions);
    	var directionsRenderer = new google.maps.DirectionsRenderer();
    	directionsRenderer.setMap(map);
    	directionsRenderer.setPanel($("#directions").get(0));
    
    	var request = {
    		origin: new google.maps.LatLng(36.52443, -91.98488),
    		destination: new google.maps.LatLng(36.63423, -91.95346),
    		travelMode: google.maps.TravelMode.DRIVING
    	};
    
    	directionsService.route(request, function(result, status) {
    		if (status == google.maps.DirectionsStatus.OK) {
    			directionsRenderer.setDirections(result); }
    	});
    });
    </script>
    </head>
    <body>
    <div id="map"></div>
    <div id="directions"></div>
    </body>
    </html>
    Last edited by sunfighter; 10-22-2013 at 11:02 PM.
    Evolution - The non-random survival of random variants.

    "If you leave hydrogen alone, for long enough, it begins to think about itself."

  • #8
    Regular Coder
    Join Date
    Apr 2013
    Posts
    158
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Thank for your help Sunfighter, I am very nearly there....


    I have a moving marker over my current location, GREAT!

    Now I just need to get my coords (lat / Long)

    so that I can set them in the following piece of code as "position" is not a variable?!

    Code:
    function calcRoute() {
    			alert("My Position:" + position + " and pub position: " + location2);
      var start = position;
      var end = location2;
      var request = {
          origin:start,
          destination:end,
          travelMode: google.maps.DirectionsTravelMode.DRIVING
      };
      directionsService.route(request, function(response, status) {
        if (status == google.maps.DirectionsStatus.OK) {
          directionsDisplay.setDirections(response);
        }
      });
    }
    google.maps.event.addDomListener(window, 'load', initialize);

  • #9
    Regular Coder
    Join Date
    Apr 2013
    Posts
    158
    Thanks
    3
    Thanked 0 Times in 0 Posts
    and I'll have to call my calcRoute function properly too as the following code doesn't work?!
    Code:
    <p><a data-role="button" data-icon="arrow-r" data-iconpos="right" data-theme="a" onclick="calcRoute(); return false">Calculate Route</a></p>

  • #10
    Senior Coder
    Join Date
    Jan 2011
    Location
    Missouri
    Posts
    4,712
    Thanks
    25
    Thanked 660 Times in 659 Posts
    I don't know what your data- types are so I just left them off. Two ways to call the js, one is a button

    Code:
    1.) <button onclick="do_map();">Calculate Route</button>
    2.) <a href="javascript:onclick = do_map()" >Calculate Route</a>
    Not sure the anchor does the return false, but the button does.
    Last edited by sunfighter; 10-23-2013 at 06:46 AM.
    Evolution - The non-random survival of random variants.

    "If you leave hydrogen alone, for long enough, it begins to think about itself."

  • #11
    Regular Coder
    Join Date
    Apr 2013
    Posts
    158
    Thanks
    3
    Thanked 0 Times in 0 Posts
    ok, so I have most things working now... when I call the calcRoute() function by clicking the button at the top: on the pub details page http://www.jbiddulph.com/pubs1/

    I get the error: ReferenceError: position is not defined

    var start = displayAndWatch(position);


    here is my code:

    Code:
    // MAP
    var map;
    // var localSearch = new GlocalSearch();
    // Wait for Cordova to load
    //
    // document.addEventListener("deviceready", onDeviceReady, false);
    
    var location2;
    var address2;
    var latlng;
    var geocoder;
    var distance;
    var directionsDisplay;
    var directionsService = new google.maps.DirectionsService();
    
    
    function checkInternet() {
    	var online = window.navigator.onLine;
    	if (!online) {
    		alert('Please check your internet connection and try again.');
    	}
    }
    
    function initialize() {
    	geocoder = new google.maps.Geocoder(); // creating a new geocode object
    	// getting the two address values
    	address2 = document.getElementById("postcode").value;
    	// finding out the coordinates
    	if (geocoder) {
    		geocoder.geocode({
    			'address': address2
    		}, function(results, status) {
    			if (status == google.maps.GeocoderStatus.OK) {
    				//location of second address (latitude + longitude)
    				location2 = results[0].geometry.location;
    				// calling the showMap() function to create and show the map
    				initLocationProcedure();
    			} else {
    				alert("Geocode was not successful for the following reason: " + status);
    			}
    		});
    	}
    }
    // creates and shows the map
    
    
    
    
    
                var map,
                    currentPositionMarker,
                    mapCenter = new google.maps.LatLng(40.700683, -73.925972),
                    map;
    
                function initializeDirectionsMap()
                {
                    directionsDisplay.setPanel(document.getElementById('directions-panel'));
                    var control = document.getElementById('control');
      control.style.display = 'block';
      map.controls[google.maps.ControlPosition.TOP_CENTER].push(control);
                }
                
                function initializeMap()
                {
                	directionsDisplay = new google.maps.DirectionsRenderer();
                    map = new google.maps.Map(document.getElementById('map'), {
                       zoom: 18,
                       center: mapCenter,
                       mapTypeId: google.maps.MapTypeId.ROADMAP
                     });
                    directionsDisplay.setMap(map);
                }
    
    			
                function locError(error) {
                    // the current position could not be located
                    alert("The current position could not be found!");
                }
    
                function setCurrentPosition(pos) {
                    currentPositionMarker = new google.maps.Marker({
                        map: map,
                        position: new google.maps.LatLng(
                            pos.coords.latitude,
                            pos.coords.longitude
                        ),
                        title: "Current Position"
                    });
                    
                    map.panTo(new google.maps.LatLng(
                            pos.coords.latitude,
                            pos.coords.longitude
                        ));
                }
    
    
                function displayAndWatch(position) {
                    // set current position
                    setCurrentPosition(position);
                    // watch position
                    watchCurrentPosition();
                }
    
                function watchCurrentPosition() {
                    var positionTimer = navigator.geolocation.watchPosition(
                        function (position) {
                            setMarkerPosition(
                                currentPositionMarker,
                                position
                            );
                        });
                }
    
                function setMarkerPosition(marker, position) {
                    marker.setPosition(
                        new google.maps.LatLng(
                            position.coords.latitude,
                            position.coords.longitude)
                    
                    );
                    
                }
                
                function calcRoute() {
    			 alert("My Position: here i am and pub position: " + location2);
      var start = displayAndWatch(position);
      var end = location2;
      var request = {
          origin:start,
          destination:end,
          travelMode: google.maps.DirectionsTravelMode.DRIVING
      };
      directionsService.route(request, function(response, status) {
        if (status == google.maps.DirectionsStatus.OK) {
          directionsDisplay.setDirections(response);
        }
      });
    }
    google.maps.event.addDomListener(window, 'load', initialize);
                
                
                
    			
    			
    
    
    
    
    
    
    
                function initLocationProcedure() {
                    initializeMap();
                    if (navigator.geolocation) {
                        navigator.geolocation.getCurrentPosition(displayAndWatch, locError);
                    } else {
                        alert("Your browser does not support the Geolocation API");
                    }
                }
    
                $(document).ready(function() {
                    
                    initLocationProcedure();
                    
                });

  • #12
    Regular Coder
    Join Date
    Apr 2013
    Posts
    158
    Thanks
    3
    Thanked 0 Times in 0 Posts
    if I put


    Code:
    var start = "Brighton";
    or


    Code:
    var start = "London";
    then it works, I need it to be where my current location is?!

  • #13
    Regular Coder
    Join Date
    Apr 2013
    Posts
    158
    Thanks
    3
    Thanked 0 Times in 0 Posts
    here is my code: http://jsfiddle.net/boyjarv/6thyT/


    Just need to change Marker A to my current location


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •