[Beginner] Getting Started with Google Map Asset


(Mark Brydon) #21

This can be done by configuring an Asset Builder to create “Google Location” assets under the Root Node used by your map.

It is also possible to allow users to create a location based on a search performed within the map. For this option, the “Enable Create Location” option must be enabled within the Map asset.



For details of how to accomplish this and further information about the Google Maps package, please consult the Google Maps manual available from our Matrix Documentation Page.


(Anurag) #22

Hi…


I got the google map asset manual… I have successfully created a google map page…listing all my google map locaiton assets… pop bubble…



I have also created a asset builder which i am calling through a javacript in Map initialization section… when user clicks on map…a pop get open in which an asset builder is nested which ask for name, email address…description…latitude and longitude… So far if i enter name and all other fields… its created a google map location asset in the fixed folder locaiton…



The issue is i have to manually enter latitude and longitude in asset builder form… Is it possible that when i click on google map it opens up a pop up and fill the latitude and longitude itself of the asset builder…





Code i am using to open pop for asset builder on user click is

======================================================================

<div id="map" style="width:600px;height:500px;border:solid 0px;" onclick="poponload()"></div>

<script type="text/javascript">

gmap_init();

window.onunload = GUnload;



GEvent.addListener(map, "click", function(overlay, point){

map.clearOverlays();



// This fucniton gives me laittude and longitude of the the map where user has clicked…



if (point) {

map.addOverlay(new GMarker(point));

map.panTo(point);

msg = "Latitude: "+point.lat()+"<br />"+"Longitude: "+point.lng();

document.getElementById("mypoint").innerHTML = msg;

document.getElementById("id_map_lat").value = point.lat();

document.getElementById("id_map_lon").value = point.lng();

}

});




// This function opens the asset builder in a pop up…

function poponload()

{

my_window= window.open ("URL_Asset_builder " , "mywindow1","width=800,height=800,toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1");



}

</script>



<div id="mypoint">Click on map to get Lat/Lon Values<br/></div>



=======================================================================



I am thinking to attach latitude nad longitude to the query string of asset builder url in javascript…



my_window= window.open ("URL_Asset_builder?Lat=???&Log=??? ")



Can any1 advice me how can i achieve this…


(Anurag) #23

hi…


well i figured out that using %globals_get_QuerystringVarName% I can get the value of latitude and longitude…



So the next final step for me to complete this google map module is… how do i make this %globals_get_Lat% value set to latitude value of the form…



I ahve a pop which is nested with asset builder whihc displays a



Name %details-F_short_name%

Email %details-F_name%

Message %details-F_description%



Latitude %details-F_latitude% %globals_get_Lat%

Longitude %details-F_longitude% %globals_get_Lang%



%commit_button%





clicking on commit button after entring all the values creates a google map locaiton asset and dispalys it on google map…



Can some please tell me how do i assign this %details-F_latitude% = %globals_get_Lat%



I dnt want to let user enter value the textbox created by %details-F_latitude%



Is their a way by whihc user just have to click on the google meap and then just enter name ,emai and message… and click commit button… long and latitude will be set in background…



Awaitng for reply… I am almost thier to complete it…


(Rachel Macdonald) #24

I don't know the answer but hope someone else does as I find the lat-long part the hiccup when it comes to google maps!


(Huan Nguyen) #25

I know this has been half a year, but i still have to reply, just in case someone else get stuck on the same thing. Sorry didn't see this post earlier.
To populate the coordinate (lat, long) to an asset builder field, this is what i do



The content for Google Map Location Create Form Layout (i guess can be default create form layout as well) for an Asset Builder


    
Location Name: %details-F_name%
Latitude: %details-F_latitude%
Longitude: %details-F_longitude%
Description: %details-F_description%


(yes i use table, it is ugly).



In the Google Map asset Details screen, you'd need to set "Enable Create Location" to yes (what this does is it is trying to find out the attribute id of the google map location's latitude and longitude attribute, so it can populate the form automatically).



In the Page Content bodycopy of the Google Map asset, you'd need to call this function

    populateAssetBuilderForm(marker, 'anydescription');


then it will populate the form lat long field with the corresponding lat long of the clicked location (marker) on the map. Note the var "marker" here is the marker object returned when you are adding a new marker on the map using an event listener - click. This would be in the Google Map API doc.

I hope this is detailed enough.