timmah1 Posted February 21, 2012 Share Posted February 21, 2012 I'm trying to make a map that will show your current location, but also load an xml file to show certain attractions in your area. Can anybody help me figure this out? I have the code to work for getting your current location, but I can't figure out how to implement loading the xml file and placing markers based off of that xml file. Here is the code for getting my location: <script> function initialize_map() { var myOptions = { zoom: 4, mapTypeControl: true, mapTypeControlOptions: {style: google.maps.MapTypeControlStyle.DROPDOWN_MENU}, navigationControl: true, navigationControlOptions: {style: google.maps.NavigationControlStyle.SMALL}, mapTypeId: google.maps.MapTypeId.ROADMAP } map = new google.maps.Map(document.getElementById("map_canvas"), myOptions); } function initialize() { if(geo_position_js.init()) { document.getElementById('current').innerHTML="Receiving..."; geo_position_js.getCurrentPosition(show_position,function(){document.getElementById('current').innerHTML="Couldn't get location"},{enableHighAccuracy:true}); } else { document.getElementById('current').innerHTML="Functionality not available"; } } function show_position(p) { document.getElementById('current').innerHTML="latitude="+p.coords.latitude.toFixed(2)+" longitude="+p.coords.longitude.toFixed(2); var pos=new google.maps.LatLng(p.coords.latitude,p.coords.longitude); map.setCenter(pos); map.setZoom(14); var infowindow = new google.maps.InfoWindow({ content: "<strong>yes</strong>" }); var marker = new google.maps.Marker({ position: pos, map: map, title:"You are here" }); google.maps.event.addListener(marker, 'click', function() { infowindow.open(map,marker); }); } </script > Link to comment https://forums.phpfreaks.com/topic/257474-google-maps-and-location/ Share on other sites More sharing options...
requinix Posted February 21, 2012 Share Posted February 21, 2012 Look into KML. Much easier. Link to comment https://forums.phpfreaks.com/topic/257474-google-maps-and-location/#findComment-1319679 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.