Help with Google Places Map and result
Have you added this visit link yourself? Or are you referring to google links? If you can post a screenshot of your info window I can have some idea
Catch up wih the Appery.io community on our forum. Here you'll find information on the lastest questions and issues Appery.io developers are discussing.
https://forum.appery.io/
Have you added this visit link yourself? Or are you referring to google links? If you can post a screenshot of your info window I can have some idea
Actually, I cannot use Google Links because I am not using Google Accounts as logins.. It's like I am creating my own repository of establishments but still want to throw the request to Google Places Library but my own repository will do the condition based on visits..
Easiest thing would be perhaps to store the location coordinates before showing the infowindow.
Then try to update your database / collection when something on the infowindow is being clicked. For example you can capture all click events this way
code
window.onclick = function (e) {
if (e.target.localName == 'a') {
console.log('clicked!');
}
}
/code
or
code
window.onclick = function(e) { alert(e.target);}; // remember to filter out unwanted elements
/code
You can also get the href or the id (if you have set one). I think its e.target.href and e.target.id (you may have to test this)
And when you are displaying the markers, you can then look up the collection for previous click - based on lat lon columns. If you find a match then you can set the "icon" property of the marker when creating the marker, and then you can have markers in different colors. The icon property can be a url like this one: http://i.stack.imgur.com/EVb1C.png
Thanks for the idea.
I am actually new to Appery. I've been using the platform for 4 days now so there are lots of things that I do not actually know.
I know this is to much but can you make an example on your idea?
[quote:]And when you are displaying the markers, you can then look up the collection for previous click - based on lat lon columns.[/quote]
is this possible to look at the collection upon throwing the request to Google Place Library?
I am actually lost and I our deadline for this project is within 5 days ![]()
it's for our school research ![]()
You've been a HUGE HELP for me. I would appreciate if you can help me with this.
You want the visits to be incremented when someone click on the More Info link in the infowindow? If yes then please provide me with the code used for the inforwindow.
As for the color of the markers, I can try to help you but I cannot assure that it will be done in 5 days as I am busy with some travel and couple of my projects. Nonetheless if I am able to squeeze in sometime I'll try to help you with that.
Hi thanks for replying!
I know this is asking too much but, Is there other way to contact you other than here on GetSatisfaction?
I basically used the same code you provided just a little tweak.. I created a separate function for createMarker then placed the infoWindow there
code
function createMarker(place) {
var placeLoc = place.geometry.location;
var marker = new google.maps.Marker({
map: map,
position: place.geometry.location,
title: placeData.name,
Code: Select all
//icon: "http://maps.google.com/mapfiles/kml/paddle/blu-circle.png", });
google.maps.event.addListener(marker, 'click', function() {
infowindow.close();
infowindow = new google.maps.InfoWindow({content: '<div style="line-height:1.35;overflow:hidden;white-space:nowrap;">'+place.name+'</br>'+place.vicinity+'</br><a href="#">Get Directions</a>'+'</br><a href="EstablishmentDetails.html">More Info</a>'+'<>'});
infowindow.open(map, this);
});
/code
Well, there are couple of ways you it.
There can be a collection where you have the following columns: placeid, userid, visits
Just before showing the search results to a user, execute a rest call to fetch the data (filter by userid) from the above collection - perhaps into an array / local storage.
When you are creating the markers - just do a look up in the local array / variable for an id equal to that place id. If it is found then look for then number of visits. Then use conditional statements to select a different marker icon.
You can also update your visits table this way - For the hyperlink leading to any place - don't directly do a href to that link but instead called a javascript function. The in that javascript you can call your REST API to update the number of visits to that place and subsequently in that function you can navigate to that place
You can also use geohashing. Each latitude longitude pair can be transformed or translated into a geohash. This geohash can also be reversed. Geohashing can also help for searching for nearby places without using other spatial queries. There are some JS libraries available too
Ya you can drop me an email decodeEmail(ripplingwater75atgmaildotcom)
About the collection, should I prepopulate it? or it will only be populated once the Visit link was clicked?
This..
[quote:]You can also update your visits table this way - For the hyperlink leading to any place - don't directly do a href to that link but instead called a javascript function. The in that javascript you can call your REST API to update the number of visits to that place and subsequently in that function you can navigate to that place [/quote]
I can't make the javascript link work..
codegoogle.maps.event.addListener(marker, 'click', function() {
var latlangs = this.position;
infowindow.close();
Code: Select all
infowindow = new google.maps.InfoWindow({content: '<div style="line-height:1.35;overflow:hidden;white-space:nowrap;">'+place.name+'</br>'+place.vicinity+'</br><a href="Directions_map.html">Get Directions</a>'+'</br><a onclick="addEst()">More Info<>'+'<>'});
infowindow.open(map, this);
localStorage.setItem('latlng', latlangs);
var est_place = place.place_id;
localStorage.setItem('est_placeid', est_place); });
bounds.extend(sfLatlng); // fitbounds
}
function addEst()
{
alert('clicked');
est_create.execute();
}
/code
infowindow More Info has the javascript function link. But it doesn't work.
When the user clicks the visit link, then fetch the data into an array. Then when you are loading the search result use that data for lookup and change the "icon" property of the marker accordingly.
For calling a JS on href click you should use this
code
<a href="javascript:void(0);" onclick="addEst();">More Info</a>
/code
if the above does not work then you can try this
code
<a href="javascript:addEst();">More Info</a>
/code