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

The Archive Base Latest Questions

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

I used to make GML vector like this: layer = new OpenLayers.Layer.GML(based, ./parser2.php, {

  • 0

I used to make GML vector like this:

layer = new OpenLayers.Layer.GML("based",
        "./parser2.php",
        {
            isBaseLayer: true,
            format: OpenLayers.Format.GeoJSON,
            styleMap: new OpenLayers.StyleMap(mystyle),
            units:"m",
            maxResolution: 0.2,
            minResolution: 0.01
        })

map.addLayer(layer);

but is now depreciated an for multiple raison i need to use OpenLayers.Layer.Vector but i can’t succed to read a geoJon file.
I tried like this:

   var test = new OpenLayers.Layer.Vector("test", {
    strategies: [new OpenLayers.Strategy.Fixed()],
    protocol: new OpenLayers.Protocol.HTTP({
        isBaseLayer: true,
        url: "data.json",
        styleMap: myStyles,
        format: new OpenLayers.Format.JSON()
        })
    });
map.addLayer(test);

but unfortunately it’s not working.

do you have any clue?

Thanks

  • 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-25T11:08:14+00:00Added an answer on May 25, 2026 at 11:08 am

    I use the steps described in the following web page to add GeoJSON format data to a layer: http://thinkwhere.wordpress.com/2011/06/26/geocommons-geojson-in-openlayers/
    As your GeoJSON is already correct format do not add {"type": "FeatureCollection", "features": ...} around the GeoJSON string, as shown in this example.

    In plain English, the steps are:

    1. Create a new OpenLayers.Layer.Vector layer without options to read data.
    2. You read the URL yourself.
    3. In the callback function called when reading is complete you create a OpenLayers.Format.GeoJSON() object, use it to read features from the GeoJSON string, then add the features to the layer.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to C#.Till this moment I used to make every global variable -
I wanted to know what code is used to make a background like this
I'd like to make a listview that used the ListView.CHOICE_MODE_SINGLE so that the user
What library is used to make a static terminal window like vim, nano, irssi
What kind of software do you think is used to make demos,like the once
What methods can be used to make PHP capable of becoming a push notification
I'm using Supersized jQuery plugin . This plugin is used to make full screen
It's been a while since I've used make , so bear with me... I've
Our application used to make use of a common base form that all forms
I used made a fft to make a band pass filter. After that I

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.