I am new to JavaScript, but this problem drove me crazy for two days and I cannot find anyone with the same problem as mine.
I am trying to add a button to hide all markers on my map (in the end I want to do this in order to hide markers by category, but hide all markers at the moment) I use the code from the Google developers website.
Here is my code
var map; var service; var infowindow; function initialize() { var pyrmont = new google.maps.LatLng(49.2755189938682, -123.1185996613159); map = new google.maps.Map(document.getElementById('map'), { mapTypeId: google.maps.MapTypeId.ROADMAP, center: pyrmont, zoom: 17 }); var request = { location: pyrmont, radius: '500', types: ['atm','bus_station','parking'] }; infowindow = new google.maps.InfoWindow(); service = new google.maps.places.PlacesService(map); service.nearbySearch(request, callback); TestMarker(); } function callback(results, status) { if (status == google.maps.places.PlacesServiceStatus.OK) { for (var i = 0; i < results.length; i++) { var place = results[i]; createMarker(results[i]); } } } function TestMarker() { CentralPark = new google.maps.LatLng(49.2755189938682, -123.1185996613159); addMarker(CentralPark); } function addMarker(location) { marker = new google.maps.Marker({ position: location, map: map, icon: "http://maps.google.com/mapfiles/ms/micons/POI.png", title: 'Sues Party, Idaburn Salon' }); } function createMarker(place) { var iconType = {}; iconType['atm'] = "http://maps.google.com/mapfiles/ms/micons/dollar.png"; iconType['bus_station'] = "http://maps.google.com/mapfiles/ms/micons/bus.png";
I added a button to call function , but I think the problem is getting the records from the array. Really stuck, any help is much appreciated. Even advice on what I need to do to make it work
James
source share