简体   繁体   中英

Openlayer center from JSON data (Ionic & Angular)

I created a simply html code where I need to show data from a JSON file. It´s running ok but I need to show a simply Openlayers map. Openlayers can show a map with center definition without javascript, but I can`t change this parameters with my json data.

Here is the code:

<div id="contact">
<h1>{{data.title}}</h1>
<p>{{data.description}}</p>
<openlayers lat="-33.86" lon="151.20" zoom="9" attribution="false">
</openlayers>
</div>

It´s running fine (showing json data) but I need to change the "lat" and "long" parameters with my json data {{data.latitude}} and {{data.latitude}}

Thanks in advance for any help :) (and sorry for my english)

I resolved this with Ngmap instead Openlayers:

<map center="{{data.latitude}}, {{data.longitude}}" zoom="17" style="width:100%; height: 90%;" disable-default-u-i="true">
            <marker position="{{data.latitude}}, {{data.longitude}}"></marker>
</map>

Very easy to use and running well on Ionic ;-)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM