@jesst446 wrote:
Hi, I have this set up for the nearby health services but how do I get it to display the nearby services
ive tried a number of ways but nothing seems to work it just goes blank whenever I change the code thats already there.here is the code :
appMap.controller('MapController', function($scope, $ionicLoading) {
google.maps.event.addDomListener(window, 'load', function() { //set London var myLatlng = new google.maps.LatLng(51.519587, -0.126324); var mapOptions = { center: myLatlng, zoom: 16, mapTypeId: google.maps.MapTypeId.ROADMAP }; var map = new google.maps.Map(document.getElementById("map"), mapOptions); navigator.geolocation.getCurrentPosition(function(pos) { map.setCenter(new google.maps.LatLng(pos.coords.latitude, pos.coords.longitude)); var myLocation = new google.maps.Marker({ position: new google.maps.LatLng(pos.coords.latitude, pos.coords.longitude), map: map, title: "My Location" }); }); $scope.map = map; });
});
the code I have for the markers is :
var map;
var infowindow;
var request;
var service;
var markers = [];function initialize() {
var center = new google.maps.LatLng(54.566160,-1.225109);
map = new google.maps.Map(document.getElementById('map'),{
center: center,
zoom: 13
});request = { location: center, radius: 1000, types: ['Health'] }; infowindow = new google.maps.InfoWindow(); service = new google.maps.places.PlacesService(map); service.nearbySearch(request, callback);
google.maps.event.addListener(map, 'rightclick', function(event) {
map.setCenter(event.latLng)var request = { location: event.latLng, radius: 1000, types: ['Health'] }; service.nearbySearch(request,callback);
};
function callback(results, status) { if (status == google.maps.places.PlaceServiceStatus.OK) { for (var i = 0; i < results.length; i++){ markers.push(createMarker(results[i])); } } } function createMarker(place) { var placeLoc = place.geometry.location; var marker = new google.maps.Marker({ maps: map, position: place.geometry.location }); google.maps.event.addListener (marker, 'click', function(); infowindow.setContent(place.name); infowindow.open(map, this); });
return marker;
}function clearResults(markers) {
for (var m in markers) {
markers {m} setMap(null)
}
markers = []
}google.maps.event.addDomListener(window, 'load', initialize);
});
Please can you tell me if this is right?
Thanks
Posts: 1
Participants: 1