Hallo ik krijg het niet voorelkaar om in de volgende code mijn huidige locatie weer te geven.
Maar in deze andere code werkt hij wel:Code:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"/> <title>Google Maps AJAX + MySQL/PHP Example</title> <link href="http://code.google.com/apis/maps/documentation/javascript/examples/default.css" rel="stylesheet" type="text/css" /> <!--<script src="http://maps.google.com/maps?file=api&v=2&key=ABQIAAAAjU0EJWnWPMv7oQ-jjS7dYxTPZYElJSBeBUeMSX5xXgq6lLjHthSAk20WnZ_iuuzhMt60X_ukms-AUg" type="text/javascript"></script> --> <script src="http://maps.google.com/maps?file=api&v=2&sensor=true&key=ABQIAAAAUcRU3zjoq8kzhEfEjIt0NhS4nbQHDc015X73zmipQetQ4i6NgRTZV-aa0LfuFOfVOMxmmSk5Zq6nCA" type="text/javascript"></script> <script type="text/javascript"> //<![CDATA[ var iconBlue = new GIcon(); iconBlue.image = 'http://maps.google.com/intl/en_us/mapfiles/ms/micons/blue-dot.png'; iconBlue.iconAnchor = new GPoint(6, 32); iconBlue.infoWindowAnchor = new GPoint(12, 5); var iconRed = new GIcon(); iconRed.image = 'http://maps.google.com/intl/en_us/mapfiles/ms/micons/red-dot.png'; iconRed.iconAnchor = new GPoint(6, 32); iconRed.infoWindowAnchor = new GPoint(12, 45); var customIcons = []; customIcons["restaurant"] = iconRed; customIcons["bar"] = iconBlue; function load() { if (GBrowserIsCompatible()) { var map = new GMap2(document.getElementById("map_canvas")); map.addControl(new GLargeMapControl()); map.addControl(new GMapTypeControl()); map.setCenter(new GLatLng(53.1955147, 5.6486204), 10); GDownloadUrl("phpsqlajax_genxml.php", function(data) { var xml = GXml.parse(data); var markers = xml.documentElement.getElementsByTagName("marker"); for (var i = 0; i < markers.length; i++) { var name = markers[i].getAttribute("name"); var address = markers[i].getAttribute("address"); var type = markers[i].getAttribute("type"); var point = new GLatLng(parseFloat(markers[i].getAttribute("lat")), parseFloat(markers[i].getAttribute("lng"))); var marker = createMarker(point, name, address, type); map.addOverlay(marker); } }); } } geoLocation(); function geoLocation() { if(navigator.geolocation) { navigator.geolocation.getCurrentPosition(function(position) { var pos = new google.maps.LatLng(position.coords.latitude, position.coords.longitude); var infowindow = new google.maps.InfoWindow({ map: map, position: pos, content: 'Hier ben ik -- Location found using HTML5.' }); map.setCenter(pos); }, function() { handleNoGeolocation(true); }); } } function createMarker(point, name, address, type) { var marker = new GMarker(point, customIcons[type]); var html = "<b>" + name + "</b> <br/>" + address; GEvent.addListener(marker, 'click', function() { marker.openInfoWindowHtml(html); }); return marker; } //]]> </script> </head> <body onload="load()" onunload="GUnload()"> <div id="map_canvas" ></div> </body> </html>
De codes moeten dus eigenlijk samengevoegd worden. En in de eerste code gaat het denk ik om dit stukjeCode:<!DOCTYPE html> <html> <head> <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: Geocoding 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="http://maps.googleapis.com/maps/api/js?sensor=true"></script> <meta name="viewport" content="initial-scale=1.0, user-scalable=no" /> <script type="text/javascript"> function detectBrowser() { var useragent = navigator.userAgent; var mapdiv = document.getElementById("map_canvas"); if (useragent.indexOf('iPhone') != -1 || useragent.indexOf('Android') != -1 ) { mapdiv.style.width = '100%'; mapdiv.style.height = '100%'; } else { mapdiv.style.width = '640px'; mapdiv.style.height = '460px'; } } var map; function initialize() { var myOptions = { zoom: 9, mapTypeId: google.maps.MapTypeId.ROADMAP }; map = new google.maps.Map(document.getElementById('map_canvas'), myOptions); // Try HTML5 geolocation if(navigator.geolocation) { navigator.geolocation.getCurrentPosition(function(position) { var pos = new google.maps.LatLng(position.coords.latitude, position.coords.longitude); var infowindow = new google.maps.InfoWindow({ map: map, position: pos, content: 'Location found using HTML5.' }); var image = 'http://maps.google.com/intl/en_us/mapfiles/ms/micons/blue-dot.png'; var marker = new google.maps.Marker({ position: pos, map: map, icon: image, content: 'Hello World!' }); var layer = new google.maps.FusionTablesLayer({ query: { select: 'Geocodable address', from: '1417386' }, }); layer.setMap(map); map.setCenter(pos); }, function() { handleNoGeolocation(true); }); } else { // Browser doesn't support Geolocation handleNoGeolocation(false); } } function handleNoGeolocation(errorFlag) { if (errorFlag) { var content = 'Error: The Geolocation service failed.'; } else { var content = 'Error: Your browser doesn\'t support geolocation.'; } var options = { map: map, position: new google.maps.LatLng(60, 105), content: content }; var infowindow = new google.maps.InfoWindow(options); map.setCenter(options.position); } google.maps.event.addDomListener(window, 'load', initialize);</script> </head> <body> <div id="map_canvas"></div> </body> </html>
Maar ik zou niet weten hoe ik daar mijn huidige locatie in verwerkt krijgt.Code:map.setCenter(new GLatLng(53.1955147, 5.6486204), 10);
Iemand een idee?
Gr. Mathijs
- Huidige locatie in google maps verwerken
-
08-09-2011, 13:01 #1
- Berichten
- 408
- Lid sinds
- 16 Jaar
Huidige locatie in google maps verwerken
-
In de schijnwerper
Plaats een
- + Advertentie
- + Onderwerp
Marktplaats
Webmasterforum
- Websites algemeen
- Sitechecks
- Marketing
- Domeinen algemeen
- Waardebepaling
- CMS
- Wordpress
- Joomla
- Magento
- Google algemeen
- SEO
- Analytics
- Adsense
- Adwords
- HTML / XHTML
- CSS
- Programmeren
- PHP
- Javascript
- JQuery
- MySQL
- Ondernemen algemeen
- Belastingen
- Juridisch
- Grafisch ontwerp
- Hosting Algemeen
- Hardware Info
- Offtopic