Jump to content

Google Maps and Location


timmah1

Recommended Posts

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.