Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8142751
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T12:54:33+00:00 2026-06-06T12:54:33+00:00

I’m parsing XML to get multiple markers directly from the database, so used the

  • 0

I’m parsing XML to get multiple markers directly from the database, so used the Google example for this. I now need to show the user’s location on the map (as the centre point). I’m finding either creating a function to load the map after the geolocation tricky, and this is where I am going wrong.

As you can see I can alert the lat & long but as the map loads first, it won’t centre the map on those co-ordinates. I have tried creating a function afterwards to run the map, but I must be missing something.
If anyone could help me that would be great – or even where to move the load function to.

A test page where I am working from is located here: http://www.musecosystems.com/app/event_map2.html

if (navigator.geolocation) 
{
    navigator.geolocation.getCurrentPosition( 

        function (position) {  
    var current_latitude = position.coords.latitude;
    var current_longitude = position.coords.longitude;
    alert ("Latitude"+current_latitude+"Longitude"+current_longitude);mapServiceProvider(position.coords.latitude,position.coords.longitude);
    }   
        );
    } 
 </script><script>



function load() {
      var map = new google.maps.Map(document.getElementById("map"), {

        center: new google.maps.LatLng(54.046575, -2.8007399),
        zoom: 16,
        mapTypeId: 'roadmap'
      });


    var infoWindow = new google.maps.InfoWindow;
          document.getElementById("map").style.width=screen.width+"px";
          document.getElementById("map").style.height=screen.height+"px";
          document.getElementById("map").style.padding="0px";
          document.getElementById("map").style.margin="0px";

      // Change this depending on the name of your PHP file
      downloadUrl("http://www.musecosystems.com/app/server/venue_output.php", function(data) {
        var xml = data.responseXML;
        var markers = xml.documentElement.getElementsByTagName("marker");
        for (var i = 0; i < markers.length; i++) {
          var name = markers[i].getAttribute("name");
          var event_name = markers[i].getAttribute("event_name");
          var event_start = markers[i].getAttribute("event_start");
          var event_link = markers[i].getAttribute("event_link");    
          var type = markers[i].getAttribute("location_status");
          var point = new google.maps.LatLng(
              parseFloat(markers[i].getAttribute("latitude")),
              parseFloat(markers[i].getAttribute("longitude")));
          var html = "<b>" + name + "</b>" + "<br/>" +("<a href='" + event_link + "'>" + event_name + "</a>");;
          var icon = customIcons[type] || {};
          var marker = new google.maps.Marker({
            map: map,
            position: point,
            icon: icon.icon,
            shadow: icon.shadow
          });
          bindInfoWindow(marker, map, infoWindow, html);
        }
      });
    }

    function bindInfoWindow(marker, map, infoWindow, html) {
      google.maps.event.addListener(marker, 'click', function() {
        infoWindow.setContent(html);
        infoWindow.open(map, marker);
      });
    }

    function downloadUrl(url, callback) {
      var request = window.ActiveXObject ?
          new ActiveXObject('Microsoft.XMLHTTP') :
          new XMLHttpRequest;

      request.onreadystatechange = function() {
        if (request.readyState == 4) {
          request.onreadystatechange = doNothing;
          callback(request, request.status);
        }
      };

      request.open('GET', url, true);
      request.send(null);
    }

    function doNothing() {}


  </script>

  </head>

  <body onload="load()">
    <div id="map" ></div>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T12:54:34+00:00Added an answer on June 6, 2026 at 12:54 pm

    I’d try the following:

    …

    <script>
        if (navigator.geolocation) {
            navigator.geolocation.getCurrentPosition(function (position) {  
                var current_latitude = position.coords.latitude;
                var current_longitude = position.coords.longitude;
                load(current_latitude, current_longitude);
            });
        } else {
            load(54.046575, -2.8007399);
        }
    </script>
    

    …

    function load(center_lat,center_lng) {
        var map = new google.maps.Map(document.getElementById("map"), {
            center: new google.maps.LatLng(center_lat, center_lng),
            zoom: 16,
            mapTypeId: 'roadmap'
    });
    

    …

    <body><div id="map"></div></body>
    

    By the way: there is a good Firefox extension called Geolocater to test if the geolocation works as expected.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
In my XML file chapters tag has more chapter tag.i need to display chapters
Does anyone know how can I replace this 2 symbol below from the string
I'm parsing an XML file, the creators of it stuck in a bunch social
I have a view passing on information from a database: def serve_article(request, id): served_article
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I used javascript for loading a picture on my website depending on which small

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.