1

i know there is the same question like mine but i still don't understand...

i want to make a google map with value in my database there are 3 value in my database: name, lat, and lon.

and i want to get this value and add this into my javascript.

here is my google map script (stil fresh from w3school) :

<script>

var myCenter=new google.maps.LatLng(51,508743,-0,12085);

function initialize()
{
var mapProp = {
  center:myCenter,
  zoom:5,
  mapTypeId:google.maps.MapTypeId.ROADMAP
  };

var map=new google.maps.Map(document.getElementById("googleMap"),mapProp);

var marker=new google.maps.Marker({
  position:myCenter,
  });

marker.setMap(map);
}

google.maps.event.addDomListener(window, 'load', initialize);
</script>

i have read this question :Getting database values in Javascript variable dynamically .

but still dont understand how it works, what do i need to add and what do i need to change. please help

2
  • fetch the data from database and replace your value with variable as below var myCenter=new google.maps.LatLng(<?php echo $lat;?>,<?php echo $lang;?>); Commented May 10, 2016 at 4:58
  • what the... its THAT simple ??? wow, i dont understand why i take the long route... i always thought you need to put the recordset or table name before the variable... thanks a lot man Commented May 10, 2016 at 5:11

1 Answer 1

2

In which language?

In PHP you have to just use your variables with db table column values in place of long and lat.

e.g. and

var myCenter=new google.maps.LatLng(,);

Let me know if you want the multiple maps with in the loop.

Vikash

Sign up to request clarification or add additional context in comments.

3 Comments

i am using dreamweaver php for my web, so yeah i am using php languange... but i dont know what to add or what to add in the script php or javacript.
thanks man... i got it now, and if i can become greedy . i want to know how to use multiple map like you said.
link Please read this tutorial. Very easy to implement.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.