I
I
ildar19892017-05-16 23:54:31
PHP
ildar1989, 2017-05-16 23:54:31

How to put labels in google map from db array?

Hello. I'm struggling with the problem of creating labels from an array. There is a DB in which coordinates of points contain. There is a web page with a google map. It is necessary to display the labels from the database into an array, as I understand it in php, and place them on the map already in javascript. There are no problems with php and database, with the map too (marks statically filled in javascript are placed). But I have no idea how to implement this in PHP + javascript. Prompt in what direction to dig.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergej, 2017-05-17
@sayber

You get data from the DB and insert it into the google maps API.
Why are you all too lazy to read the documentation for what you are going to work with.
https://developers.google.com/maps/documentation/j...
The easiest way is to have an array with coordinates

// Multiple Markers
    var markers = [
        ['London Eye, London', 51.503454,-0.119562],
        ['Palace of Westminster, London', 51.499633,-0.124755]
    ];

and further in the loop during initialization, insert the whole thing
for( i = 0; i < markers.length; i++ ) {
// ...
        var position = new google.maps.LatLng(markers[i][1], markers[i][2]);
        marker = new google.maps.Marker({
            position: position,
            map: map,
            title: markers[i][0]
        });
// ...

There are hundreds of examples on google.
So you got a job as a cook.
You receive an order for french fries. You take a dirty whole potato and serve it. And you think it's okay. But first you need to read what to do with potatoes, then read how to cut it and how to cook it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question