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

  • SEARCH
  • Home
  • 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 7188533
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T19:06:21+00:00 2026-05-28T19:06:21+00:00

I have a problem that I have not managed to solve. I developed a

  • 0

I have a problem that I have not managed to solve.

I developed a small script to load a Google Map. This script uses HTML 5 to determine your current location and then shows you some places on the map. These are places that are read from a MySQL database.

The issue is that somehow I need to filter them by category. A PHP file is responsible for generating an XML file from the MySQL database.

I could pass the following parameter to select the category: file.php?category=something

downloadUrl("file.php?cat=something", function(data) {
        var markers = data.documentElement.getElementsByTagName("marker");
        for (var i = 0; i < markers.length; i++) {
        var latlng = new google.maps.LatLng(parseFloat(markers[i].getAttribute("lat")),
        parseFloat(markers[i].getAttribute("lng")));
        var marker = createMarker(markers[i].getAttribute("name"), markers[i].getAttribute("address"), markers[i].getAttribute("type"), latlng);
        }
        });

The issue is that I want to go changing category when I click on a link for example.

Imagine you have a map to the left and right categories. Then when clicking on a category, the map automatically remove the places marked on the current category and only shows the new category.

In conclusion, the part where it says file.php? Category = something, the value “something” should be changed dynamically.

I think it could do with Jquery but I do not know exactly how. I tried several ways and still not do it.

I just need a way to change the value of this part and that the map will automatically disable the other categories, for example:

var something = doctor;
downloadUrl("file.php?cat="+something, function(data) {

This is the complete code of my script:

<!DOCTYPE html>
<html>
  <head>
    <title>Geolocalización</title>
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no">
    <meta charset="UTF-8">
    <link href="estilo.css" rel="stylesheet" type="text/css">

    <script type="text/javascript" src="http://code.jquery.com/jquery-1.7.1.js"></script>
    <script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=true"></script>
    <script type="text/javascript" src="util.js"></script>

  </head>
    <body onload="initialize()">
    <div id="info"></div>
        <div id="map_canvas" style="width: 780px; height: 600px; margin: 0 auto;"></div>

    <script type="text/javascript">
        var map;
        var infowindow;
        var geocoder;
        var marker;

        function initialize() {
        var myOptions = {
          zoom: 14,
          mapTypeId: google.maps.MapTypeId.ROADMAP
        };

        var map = new google.maps.Map(document.getElementById('map_canvas'), myOptions);

        downloadUrl("phpsqlajax_genxml.php?cat=doctor", function(data) {
        var markers = data.documentElement.getElementsByTagName("marker");
        for (var i = 0; i < markers.length; i++) {
        var latlng = new google.maps.LatLng(parseFloat(markers[i].getAttribute("lat")),
        parseFloat(markers[i].getAttribute("lng")));
        var marker = createMarker(markers[i].getAttribute("name"), markers[i].getAttribute("address"), markers[i].getAttribute("type"), latlng);
        }
        });

        function createMarker(name, address, type, latlng) {

        if(type=="doctor"){
        var image = 'clinicas-y-hospitales.png';
        }else{
        var image = 'carabineros-y-seguridad.png';
        }

        var contentString = '<h2>'+name+'</h2> <br /><p>'+address+'</p>';   

        var marker = new google.maps.Marker({position: latlng, map: map, icon: image});
        google.maps.event.addListener(marker, "click", function() {
        if (infowindow) infowindow.close();
            infowindow = new google.maps.InfoWindow({content: contentString, maxWidth: 200});
            infowindow.open(map, marker);
        });
        return marker;
        }

        geocoder = new google.maps.Geocoder();

        // Try HTML5 geolocation
        if(navigator.geolocation) {
          navigator.geolocation.getCurrentPosition(function(position) {
            var pos = new google.maps.LatLng(position.coords.latitude,
            position.coords.longitude);
            map.setCenter(pos);

        geocoder.geocode({'latLng': pos}, function(results, status) {
        if (status == google.maps.GeocoderStatus.OK) {
        if (results[1]) {
          marker = new google.maps.Marker({
              position: pos,
              map: map
          });

          infowindow = new google.maps.InfoWindow({content: '<p><strong>Usted está aquí:</strong> '+results[1].formatted_address+'</p>'});
          infowindow.open(map, marker);

          document.getElementById('info').innerHTML = results[1].formatted_address;
        }
        } else {
        alert("Geocoder failed due to: " + status);
        }
        });

          }, function() {
            handleNoGeolocation(true);
          });

        } else {
          // Browser doesn't support Geolocation
          handleNoGeolocation(false);
        }
      }

        function handleNoGeolocation(errorFlag) {
        if (errorFlag) {
          var content = 'Error: La geolocalización ha fallado.';
        } else {
          var content = 'Error: Tu navegador no soporta geolocalización.';
        }

        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>

    </body>
</html>

To see the script running are here:

http://pruebas.davidbanner.cl/geo/index.php

A similar example of what I need to do is here:

http://mapas.vinadelmarchile.cl/index.php

Thank you very much to anyone who can give me an idea or help with code.

Greetings.

  • 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-05-28T19:06:22+00:00Added an answer on May 28, 2026 at 7:06 pm

    You should try to let’s say put a button or link and on the click event implement the call to get the xml.

    If you need further assistance please make a working example in jsfiddle (example) and post it here in the comments so we can take a look.

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

Sidebar

Related Questions

I have a strange problem that I could not solve. When I try to
I have a problem that I have not faced before: It seems that the
I have the odd problem that I am not able to open the properties
I have encountered a problem that I have not come accross yet when setting
I have a problem that someone introduced a bug but I do not know
Here is a hum-dinger of a problem that I have not found an answer
I have developed an AR application for iPad2 that uses an ImageMarker to display
This is more of an intriguing problem than anything else since I have managed
I have been trying to solve this problem all day, I googled a lot,
In a couple of scripts that I use I have problem that is intermittent.

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.