Page 5 of 6

Help with Google Places Map and result

Posted: Sat Jan 31, 2015 6:14 pm
by M&M

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


Help with Google Places Map and result

Posted: Sat Jan 31, 2015 6:18 pm
by Poll David

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..

I only have this. and the links aren't working yet
Image


Help with Google Places Map and result

Posted: Sat Jan 31, 2015 6:47 pm
by M&M

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)


Help with Google Places Map and result

Posted: Sat Jan 31, 2015 6:54 pm
by M&M

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


Help with Google Places Map and result

Posted: Sun Feb 01, 2015 3:06 pm
by Poll David

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.


Help with Google Places Map and result

Posted: Mon Feb 02, 2015 9:06 am
by M&M

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.


Help with Google Places Map and result

Posted: Mon Feb 02, 2015 10:17 am
by Poll David

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&#46;maps&#46;InfoWindow({content: '<div style="line-height:1&#46;35;overflow:hidden;white-space:nowrap;">'+place&#46;name+'</br>'+place&#46;vicinity+'</br><a href="#">Get Directions</a>'+'</br><a href="EstablishmentDetails&#46;html">More Info</a>'+'<>'});
infowindow&#46;open(map, this);
});
/code


Help with Google Places Map and result

Posted: Tue Feb 03, 2015 5:52 am
by M&M

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)


Help with Google Places Map and result

Posted: Tue Feb 03, 2015 1:35 pm
by Poll David

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&#46;maps&#46;event&#46;addListener(marker, 'click', function() {
var latlangs = this&#46;position;
infowindow&#46;close();

Code: Select all

  infowindow = new google&#46;maps&#46;InfoWindow({content: '<div style="line-height:1&#46;35;overflow:hidden;white-space:nowrap;">'+place&#46;name+'</br>'+place&#46;vicinity+'</br><a href="Directions_map&#46;html">Get Directions</a>'+'</br><a onclick="addEst()">More Info<>'+'<>'}); 

 infowindow&#46;open(map, this); 
   localStorage&#46;setItem('latlng', latlangs); 
    var est_place = place&#46;place_id; 
   localStorage&#46;setItem('est_placeid', est_place); 

});
bounds&#46;extend(sfLatlng); &#47;&#47; fitbounds
}

function addEst()
{
alert('clicked');
est_create&#46;execute();
}
/code

infowindow More Info has the javascript function link. But it doesn't work.


Help with Google Places Map and result

Posted: Tue Feb 03, 2015 2:55 pm
by Murali

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