Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 732423
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T07:08:25+00:00 2026-05-14T07:08:25+00:00

I am creating a map using the new(ish) v3 of the Google Maps API

  • 0

I am creating a map using the new(ish) v3 of the Google Maps API

I have managed to get a map displaying using code as below:

var myLatlng = new google.maps.LatLng(50.8194000,-0.1363000);

    var myOptions = {
        zoom: 14,
        center: myLatlng,
        mapTypeControl: false,
        scrollwheel: false,
        mapTypeId: google.maps.MapTypeId.ROADMAP
    };

 var map = new google.maps.Map(document.getElementById("location-map"), myOptions);

However I now want to add a number of markers I have stored in a PHP array.

The Array currently looks like this if I print it out to screen:

Array
(
[0] => Array
    (
        [poiUid] => 20
        [poiName] => Brighton Cineworld
        [poiCode] => brighton-cineworld
        [poiLon] => -0.100450
        [poiLat] => 50.810780
        [poiType] => Cinemas
    )

[1] => Array
    (
        [poiUid] => 21
        [poiName] => Brighton Odeon
        [poiCode] => brighton-odeon
        [poiLon] => -0.144420
        [poiLat] => 50.821860
        [poiType] => Cinemas
    )
)

All the reading I have done so far suggests I turn this into JSON by using json_encode

If I run the Array though this and echo it to the screen I get:

[{"poiUid":"20","poiName":"Brighton Cineworld","poiCode":"brighton-cineworld","poiLon":"-0.100450","poiLat":"50.810780","poiType":"Cinemas"},{"poiUid":"21","poiName":"Brighton Odeon","poiCode":"brighton-odeon","poiLon":"-0.144420","poiLat":"50.821860","poiType":"Cinemas"}]

The bit now is where I am struggling, I am not sure the encoded array is what I need to start populating markers, I think I need something like the code below but not sure how to add the markers from my passed through JSON

var locations = $jsonPoiArray;
  for (var i = 0;i < locations.length; i += 1) {
  // Create a new marker

  };
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T07:08:26+00:00Added an answer on May 14, 2026 at 7:08 am

    Well I think I have solved it, however if it is a stupid way of doing it please leave an answer!

    I ended up using

    var poiJson = <? echo $jsonArray ?>;
    
        for (var i = 0;i < poiJson.length; i += 1) {
            var lat = poiJson[i].poiLat;
            var lon = poiJson[i].poiLon;
            addMarker(lat,lon,i);
        };
    
        function addMarker(lat,lng,no){
        var latlng = new google.maps.LatLng(lat,lng);  
        var marker = new google.maps.Marker({
        position: latlng,
        map: map
        });
        };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.