L
L
limpopo19922015-04-12 12:29:53
PHP
limpopo1992, 2015-04-12 12:29:53

Yandex API Map not being created?

Good time of the day!
The problem is this:
There is a certain div

<div id="rez" style="width:1000px;height:1000px">Тут будет наша замечательная карта
</div>

It is drawn on the page when it is loaded
. Next comes the form, the fields of which the user fills in and clicks on the button, then this event is picked up by a function that passes the field values ​​to the php script, then it receives the response from the script and inserts it into our div.
PHP script response content:
function one(){
var myMap = new ymaps.Map("map", {
        center: [55.76, 37.64],
        zoom: 10
    }); 
    
  //myGeoObject = new ymaps.GeoObject({
        //geometry: {
           // type: "Point",// тип геометрии - точка
           // coordinates: [jsondata.w,jsondata.l] // координаты точки
       //}
   // })
    //i = i+1;
    
//myMap.geoObjects.add(myGeoObject); // Размещение геообъекта на карте.
}
one();

As a result, I have this thing in the console: Uncaught TypeError: Cannot read property 'offsetWidth' of
null I get it as a result of working out the script.
PS Libraries of Yandex maps are connected.
What should I do? Broke his whole head.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Evgeny Petrov, 2015-04-12
@limpopo1992

Some kind of tin with logic ...
1. All functions are written in advance and the script with them is loaded initially.
2. The user clicks on the button and receives the data (certainly better in JSON).
3. This data (coordinates etc.) is passed to the function and it uses it to initialize the map.
4. If the map has already been created, and you can click on the button again, you can either re-create it or correct the current one. You don't need to insert anything into
the block, destined by fate to be a container for the map .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question