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 661817
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T23:18:35+00:00 2026-05-13T23:18:35+00:00

I have a map with 4 layers, each layer having markers for various shops.

  • 0

I have a map with 4 layers, each layer having markers for various shops. What I need to do is this.

  • User chooses shop from select
  • Script grabs shop name and then finds the correct data for that shop from json.

I have a rough idea of how the script should look but don’t know how to write it correctly.

$('#shopselect').change(function() {
    $.ajax({
    type: "GET",
    url: "data.txt",
    dataType: "json",
    success: function(data) {

    var selected = $('#shopselect option:selected').text()

    if ($(".layer1:visible").length) {
        $("#viewport").mapbox("center", { 
            x: shops." + selected + ".l1x, 
            y: shops." + selected + ".l1y 
        });
    } else if ($(".layer2:visible").length) {
        $("#viewport").mapbox("center", { 
            x: shops." + selected + ".l2x, 
            y: shops." + selected + ".l1y 
        });
    } else if ($(".layer3:visible").length) {
        $("#viewport").mapbox("center", { 
            x: shops." + selected + ".l3x, 
            y: shops." + selected + ".l1y 
        });
    } else if ($(".layer4:visible").length) {
        $("#viewport").mapbox("center", { 
            x: shops." + selected + ".l4x, 
            y: shops." + selected + ".l1y 
        });
    }
}
});

The json looks like so.

{
shops:{
    primark:{
        l1x:310,
        l1y:132,
        l2x:388,
        l2y:264,            
        l3x:530,
        l3y:355,
        l4x:670,
        l4y:450
    },
    boots:{
        l1x:310,
        l1y:132,
        l2x:388,
        l2y:264,            
        l3x:530,
        l3y:355,
        l4x:670,
        l4y:450
    }       
}

}

Is there anyone who could point me in the right direction.

  • 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-13T23:18:35+00:00Added an answer on May 13, 2026 at 11:18 pm

    Instead of using this :

    x: shops." + selected + ".l1x, 
    y: shops." + selected + ".l1y 
    

    What about something like that :

    x: data.shops[selected].l1x, 
    y: data.shops[selected].l1y 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a map with various markers and i need to be able to
I have a Google Map that loads a layer of markers from a KML
I have a map in OpenLayers that has a number of layers with Markers.
I have an OpenLayers map with a TMS layer. For each zoom change, my
I have map with multiple different colors markers with some info window. Everything works
I have a map of the UK broken down into various geographic regions. I
I have a map that i want to update from a separate thread. Im
I have image map that can I move, but this map will be so
I have a map<int int> . I need to get a vector of the
TLDR : I have an Openlayers map with a layer called 'track' I want

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.