Openlayers add point "PHP request MySQL database to return Geojson data"

Source: Internet
Author: User



PHP requests the MySQL database to return the Geojson data the implementation method see:



Http://www.cnblogs.com/marost/p/6234514.html



Openlayers "V3.19.1-dist" Add Geojson data source layer


<!doctype html>
<html lang="en">
  <head>
    <link rel=‘stylesheet‘ href=‘ol.css‘>
    <style>
      #map {
        height: 100%;
        width: 100%;
      }
    </style>
    <title>OpenLayers 3 example</title>
    <script src="ol.js" type="text/javascript"></script>
  </head>
  <body>
    <h1>My Map</h1>
    <div id="map"></div>
    <script type="text/javascript">
      var raster = new ol.layer.Tile({
        source: new ol.source.OSM()
      });

      var vector = new ol.layer.Vector({
        source: new ol.source.Vector({
          url: ‘http://yourip/getPosition.php‘,
          format: new ol.format.GeoJSON()
        })
      });

      var map = new ol.Map({
        layers: [raster, vector],
        target: ‘map‘,
        view: new ol.View({
          center: [0, 0],
          zoom: 2
        })
      });
    </script>
  </body>
</html>





Openlayers add point "PHP request MySQL database to return Geojson data"


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.