Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Google Map api markers Javascript
- var MeetingType = document.getElementById("Meeting_Type");
- var type = MeetingType.options[MeetingType.selectedIndex].text;
- var DayofMeeting = document.getElementById("Day_of_Meeting");
- var day = DayofMeeting.options[DayofMeeting.selectedIndex].text;
- var TimeofMeeting = document.getElementById("Time_of_Meeting");
- var time = TimeofMeeting.options[TimeofMeeting.selectedIndex].text;
- for (var i = 0; i < placemarkers.length; i++) {
- if (placemarkers[i].type==type&&placemarkers[i].day==day&&placemarkers[i].time==time){
- placemarkers[i].setMap(MYMAP.map);
- }else{
- clearOverlays();
- mymarkers=[]
- }
- }
- }
- $(document).ready(function() {
- $("#map").css({
- height: 500,
- width: 600
- });
- var myLatLng = new google.maps.LatLng(43.653823, -79.382843);
- MYMAP.init('#map', myLatLng, 11);
- $("#showmarkers").click(function(e){
- MYMAP.placeMarkers('include/xml.php');
- });
- });
- 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();
- }
- var markerfilter = new Array();
- 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();
- var address2 = $(this).find('address2').text();
- var Meeting_Type = $(this).find('Meeting_Type').text();
- var Time_of_Meeting = $(this).find('Time_of_Meeting').text();
- var Day_of_Meeting = $(this).find('Day_of_Meeting').text();
- var Open_Meeting = $(this).find('Open_Meeting').text();
- var Wheelchair = $(this).find('Wheelchair').text();
- var ASL = $(this).find('ASL').text();
- var Comments = $(this).find('Comments').text();
- markerfilter.push(marker);
- var MeetingType = document.getElementById("Meeting_Type");
- var type = MeetingType.options[MeetingType.selectedIndex].text;
- var DayofMeeting = document.getElementById("Day_of_Meeting");
- var day = DayofMeeting.options[DayofMeeting.selectedIndex].text;
- var TimeofMeeting = document.getElementById("Time_of_Meeting");
- var time = TimeofMeeting.options[TimeofMeeting.selectedIndex].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,
- map: MYMAP.map
- });
- var infoWindow = new google.maps.InfoWindow();
- var html='<b><u>'+name+'</b></u><br />'+address2+'<br />'+address+'<br />'+Meeting_Type+', '+Time_of_Meeting+', '+Day_of_Meeting+'<br />Open Meeting: '+Open_Meeting+'<br />Wheelchair Accessible: '+Wheelchair+'<br />ASL: '+ASL+'<br />Comments: '+Comments;
- google.maps.event.addListener(marker, 'click', function() {
- infoWindow.setContent(html);
- infoWindow.open(MYMAP.map, marker);
- });
- MYMAP.map.fitBounds(MYMAP.bounds);
- });
- });
- }
Add Comment
Please, Sign In to add comment