OR
OR
    $("#cityBtn2").click(function(){ var city=$("#city").val(); //alert(city); }); $(document).ready(function() { var myLatLng = new google.maps.LatLng(42.98580, -85.63948); MYMAP.init('#result', myLatLng, 11); $("#cityBtn").click(function(e){ $("#loaderP").show(); var city=$("#city").val(); $("#result").remove(); $("#two").append('
    '); var myLatLng = new google.maps.LatLng(42.98580, -85.63948); MYMAP.init('#result', myLatLng, 11); MYMAP.placeMarkers('store-city-result.php?city='+city+''); $(".close").click(); $('#two ol').empty(); $.ajax({ type: "GET", url: "store-city-result.php?city="+city+"", dataType: "xml", success: function(xml) { $(xml).find('marker').each(function(){ var name_text = $(this).find('name').text(); var lat_text = $(this).find('lat').text(); var lng_text = $(this).find('lng').text(); var address_text = $(this).find('address').text(); var name_text = $(this).find('name').text(); $('
  1. ') .html(''+name_text) .appendTo('#two ol'); }); //close each( } }); //close $.ajax( }); $("#zipBtn").click(function(e){ $("#loaderP").show(); var zipcode=$("#zipcode").val(); $("#result").remove(); $("#two").append('
    '); var myLatLng = new google.maps.LatLng(42.98580, -85.63948); MYMAP.init('#result', myLatLng, 11); MYMAP.placeMarkers('store-zip-result.php?zipcode='+zipcode+''); $(".close").click(); $('#two ol').empty(); $.ajax({ type: "GET", url: "store-zip-result.php?zipcode="+zipcode+"", dataType: "xml", success: function(xml) { $(xml).find('marker').each(function(){ var name_text = $(this).find('name').text(); var lat_text = $(this).find('lat').text(); var lng_text = $(this).find('lng').text(); var address_text = $(this).find('address').text(); var name_text = $(this).find('name').text(); $('
  2. ') .html(''+name_text) .appendTo('#two ol'); }); //close each( } }); //close $.ajax( }); }); $(document).ready(function() { $("#cityBtn2").click(function(e){ $("#loaderP").show(); var city=$("#city2").val(); $("#result").remove(); $("#two").append('
    '); var myLatLng = new google.maps.LatLng(42.98580, -85.63948); MYMAP.init('#result', myLatLng, 11); MYMAP.placeMarkers('store-city-result.php?city='+city+''); $(".close").click(); $('#two ol').empty(); $.ajax({ type: "GET", url: "store-city-result.php?city="+city+"", dataType: "xml", success: function(xml) { $(xml).find('marker').each(function(){ var name_text = $(this).find('name').text(); var lat_text = $(this).find('lat').text(); var lng_text = $(this).find('lng').text(); var address_text = $(this).find('address').text(); var name_text = $(this).find('name').text(); $('
  3. ') .html(''+name_text) .appendTo('#two ol'); }); //close each( } }); //close $.ajax( }); $("#zipBtn2").click(function(e){ $("#loaderP").show(); var zipcode=$("#zipcode2").val(); $("#result").remove(); $("#two").append('
    '); var myLatLng = new google.maps.LatLng(42.98580, -85.63948); MYMAP.init('#result', myLatLng, 11); MYMAP.placeMarkers('store-zip-result.php?zipcode='+zipcode+''); $(".close").click(); $('#two ol').empty(); $.ajax({ type: "GET", url: "store-zip-result.php?zipcode="+zipcode+"", dataType: "xml", success: function(xml) { $(xml).find('marker').each(function(){ var name_text = $(this).find('name').text(); var lat_text = $(this).find('lat').text(); var lng_text = $(this).find('lng').text(); var address_text = $(this).find('address').text(); var name_text = $(this).find('name').text(); $('
  4. ') .html(''+name_text) .appendTo('#two ol'); }); //close each( } }); //close $.ajax( }); }); $(document).delegate('.lis', 'click', function(){ var lat = $(this).attr('data-lat'); var lng = $(this).attr('data-lng'); var address = $(this).attr('data-address'); var name = $(this).attr('data-name'); //alert(lat); //alert(lng); var point = new google.maps.LatLng(parseFloat(lat),parseFloat(lng)); var marker = new google.maps.Marker({ position: point, icon:'barPin.png', map: MYMAP.map }); var infoWindow = new google.maps.InfoWindow(); //var html=''+name+'
    '+address; var html=''+address; infoWindow.setContent(html); infoWindow.open(MYMAP.map, marker); MYMAP.map.panTo(new google.maps.LatLng(lat, lng)); MYMAP.map.setZoom(17); }); var selectedInfoWindow; var MYMAP = { map: null, bounds: null } MYMAP.init = function(selector, latLng, zoom) { var myOptions = { zoom:zoom, center: latLng, mapTypeId: google.maps.MapTypeId.ROADMAP } this.map = new google.maps.Map($(selector)[0], myOptions); this.bounds = new google.maps.LatLngBounds(); } MYMAP.placeMarkers = function(filename) { $.get(filename, function(xml){ $(xml).find("marker").each(function(){ var name = $(this).find('name').text(); var address = $(this).find('address').text(); // create a new LatLng point for the marker var lat = $(this).find('lat').text(); var lng = $(this).find('lng').text(); var point = new google.maps.LatLng(parseFloat(lat),parseFloat(lng)); // extend the bounds to include the new point MYMAP.bounds.extend(point); var marker = new google.maps.Marker({ position: point, icon:'barPin.png', map: MYMAP.map }); var infoWindow = new google.maps.InfoWindow(); //var html=''+name+'
    '+address; var html=''+address; //var html=''+address+'
    '; /*google.maps.event.addListener(marker, 'click', function() { infoWindow.setContent(html); infoWindow.open(MYMAP.map, marker); });*/ google.maps.event.addListener(marker, 'click', function() { infoWindow.setContent(html); if (selectedInfoWindow != null && selectedInfoWindow.getMap() != null) { selectedInfoWindow.close(); //If the clicked window is the selected window, deselect it and return if (selectedInfoWindow == infoWindow) { selectedInfoWindow = null; return; } } //If arrive here, that mean you should open the new info window //because is different from the selected selectedInfoWindow = infoWindow; infoWindow.open(MYMAP.map, marker); }); MYMAP.map.fitBounds(MYMAP.bounds); $("#loaderP").hide(); }); }); }